Multi Rest v2
Multi rest is a swiss knife for handling multi-part requests for restify, and as all Node.js frameworks use HTTP server at the end so I built this dealing with HTTP requests, this module can handle diffrent files and process them.
| version 2 is received huge update from the last version with the thumbnails for images and videos
Features:
- Path handler.
- File naming.
- Upload more then one file in the same request.
- Thumbnails for images & videos.
- S3 support for AWS.
- Upload certain extensions.
In progress
- Handling multiple files under the same fieldname.
- ......
Example for disk:
const restify = ;const Multi = ;const uuid = ; var server = restify; var upload_disk = driver: type: 'local' path: "./uploads/" { // the extention will be added automaticlly return uuid; } filefields: video: type: 'video' thumbnail: width: 100 time: '10%' count: 1 required: false extensions: 'mp4' image: type: 'picture' thumbnail: width: 400 height: 300 required: false extensions: 'png' 'jpg' ; server;server;server; server; server;
Example for s3:
check how to configure AWS-SDK for Nodejs
You need to create AWS credentials to ~/.aws/credentials
[default]
aws_access_key_id = your_access_key
aws_secret_access_key = your_secret_key
Test code:
const restify = ;const Multi = ;const uuid = ; var server = restify; var upload_s3 = driver: type: 's3' endpoint: 's3-accelerate.amazonaws.com' signatureVersion: 'v4' region: 'eu-central-1' bucketName: 'test' path: '' { // the extention will be added automaticlly return uuid; } filefields: video: type: 'video' thumbnail: height: 100 time: '10%' '40%' count: 2 required: false extensions: 'mp4' image: type: 'picture' thumbnail: width: 400 height: 300 required: false extensions: 'png' 'jpg' ; server;server;server;server; server; server;
File naming
Random
This uses a uuid
v4 library to create the file name
{ return uuid;}
Same name
This uses the name of the uploaded file .
{ return name;}
Plus date
This will add file upload timestamp after the file name.
{ return name + ;}
Date
This use new Date()
to create the file name (not prefered when uploading more then one file)
{ return ;}
License
Licensed under MIT
Author
M. Mahrous developed at The D. GmbH Feel free to contact me M. Mahrous and improve the code.