sails-hook-uploads

0.4.3 • Public • Published

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

Package Sidebar

Install

npm i sails-hook-uploads

Weekly Downloads

481

Version

0.4.3

License

MIT

Unpacked Size

51.7 kB

Total Files

11

Last publish

Collaborators

  • mikermcneil
  • rachaelshaw