Skip to content

Latest commit

 

History

History
37 lines (23 loc) · 1.37 KB

README.md

File metadata and controls

37 lines (23 loc) · 1.37 KB

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-uploads

Usage

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 undefined or 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