0.2.0 • Published 4 months ago

nextdrive v0.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 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

4 months ago

0.1.0

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago