Package Exports
- sails-hook-uploads
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sails-hook-uploads) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sails-hook-uploads
Adds an easier interface for working with file uploads and downloads in your Node.js/Sails app. Supports async/await.
Only supports Node 8 and up.
npm install sails-hook-uploadsUsage
var uploaded = await sails.uploadOne(inputs.someFile);Available methods:
- .uploadOne(upstreamOrReadable) (accepts any Readable stream, or an incoming Sails file upload of 0 or 1 file; returns either
undefinedor a dictionary w/ information about the uploaded file data.) - .upload(upstream) (accepts any incoming Sails file upload -- whether it consists of 0, 1, or ≥2 files; returns an array regardless.)
- .reservoir(upstreamOrReadable) (accepts any Readable stream, or any incoming Sails file upload -- whether it consists of 0, 1, or ≥2 files; returns an array regardless.)
- .startDownload(fd) (useful for downloading a file; returns a Readable)
- .cp(srcFd, srcOpts, destOpts) (useful for transloading an already-uploaded file to a different destination)
- .rm(fd)
- .ls()
All methods use configuration from sails.config.uploads. Most inherited settings can be overridden (see source code for details- it's pretty simple in there).
For more usage tips, see the Ration.io example app and tutorial course.
License
MIT
© 2017-present Rachael Shaw, Mike McNeil