asinode-fileupload
v1.0.5
Published
Component takes request and response as parameters. File can be stored locally on the webserver or can be read using busboy and uploaded to azure.
Readme
asinode-fileupload
Component takes request and response as parameters. File can be stored locally on the webserver or can be read using busboy and uploaded to azure.
Installation
To install this Component, run yarn add asinode-fileupload or npm install --save asinode-fileupload.
Setup
// Import the component
const FileUpload = require('asinode-fileupload')
// Setup for local storage..
FileUpload.setup('<folder-path>')
// ..or Setup for Azure
const AzureStorageConfig = path.resolve(__dirname, '../storageConfig.json')
FileUpload.setup(AzureStorageConfig, '<container-name>')Usage
// Setup server endpoint
server.post('/upload', function (req, res) {
FileUpload.handleUpload(req, res, successResponse)
})
// Success response (optional)
function successResponse(res){
res.writeHead(200)
res.end('Upload complete!')
}