0.2.0 • Published 6 months ago

nextdrive v0.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

A lightweight Node.js based file server for modern apps

Install

npm install nextdrive

Usage

import NextDriveServer from 'nextdrive';

const server = new NextDriveServer({
    port:3000,
    apiKey: process.env.API_KEY,
});

server.start();

Optional Parameters

folder: default to '{working dir}/uploads'

options.cors: Allow CORS

options.allowedDomains: Allow CORS only for certain domains

API Endpoints

POST /upload/{foldername}

To upload files to the drive. Just send as Formdata. Rest will be handled and returns the file name to store in your db.

const formData = new FormData();
formData.append('files', file);


fetch('http://localhost:3000/upload/{foldername}', 
{
    method: 'POST',
    body : formData,
    {
        headers : {
            'X-API-KEY' : 'API_KEY_ADDED_IN_CONFIGS'
        }
    }
});

// OUTPUTS: File name & details

File access:

http://{root_url}/uploads/{foldername}/{filename}

DELETE /{foldername}

To delete files from the drive. Send file names as an Array

const formData = new FormData();
formData.append('files', [filenames]);


fetch('http://localhost:3000/{foldername}', 
{
    method: 'DELETE',
    body : formData,
    {
        headers : {
            'X-API-KEY' : 'API_KEY_ADDED_IN_CONFIGS'
        }
    }
});
0.2.0

6 months ago

0.1.0

12 months ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago