Package Exports
- skipper
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 (skipper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Streaming Multipart File Upload Parsing
Skipper is an opinionated variant of Connect's body parser designed to support streaming upload of monolithic files to a compatible blob receiver, while still allowing application code to run in a timely manner; without writing .tmp files to disk.
This module
maywill be included as a part of the stable release of Sails v0.10. However we need help with documentation, examples, and writing additional receivers (currently receivers for S3 and local disk exist.) The decision to include skipper in v0.10 was tough-- it has stalled our release. However, it was a consequence of rewriting this module to use streams2, as well as the spotty/fragmented/confusing state of file uploads around the community. We hope this module helps clear things up for everybody.
Installation
npm install skipper --saveWith Sails (v0.10.0)
As of v0.10.0-rc6, skipper is installed as the default request body parser in Sails- you don't need to install it again.
With Sails (v0.9.x)
To use skipper with an existing v0.9.x Sails app, you'll need to install skipper, then modify config/express.js:
module.exports.express = {
bodyParser: require('skipper')
};With Express/Connect
This module is a drop-in replacement for the default Connect bodyParser, so if you're already using that bodyParser (app.use(express.bodyParser)), you'll need to replace it and hook up skipper instead.
e.g. in the module where you set up your middleware:
// ...
app.use(require('skipper')());
// ...Usage
req.file(foo) returns a stream of binary streams- one for each file that was uploaded to the specified parameter (foo) via an HTTP multipart file upload. As is true with most middleware, the usage is identical between Sails and Express.
With Sails
In one of your controller actions:
// ...
upload: function (req, res) {
var SomeReceiver = require('../receivers/someReceiver');
req.file('avatar').upload( SomeReceiver() , function (err, files) {
if (err) return res.serverError(err);
return res.json({
message: files.length + ' file(s) uploaded successfully!',
files: files
});
});
}
// ...With Express
app.post('/upload', function uploadAction (req, res) {
var SomeReceiver = require('./receivers/someReceiver');
req.file('avatar').upload( SomeReceiver() , function (err, files) {
if (err) return res.send(500, err);
return res.json({
message: files.length + ' file(s) uploaded successfully!',
files: files
});
});
});Status
Currently, this project is in beta, and openly released on npm. Development takes place on the master branch.
More Resources
- Stackoverflow
- #sailsjs on Freenode (IRC channel)
- Professional/enterprise
- Tutorials
- Waterline (ORM)
License
MIT © 2014 Mike McNeil, Scott Gress, Balderdash & contributors
This module is part of the Sails framework, and is free and open-source under the MIT License.

