streaming multipart parser for node.js
JavaScript
Switch branches/tags
Nothing to show
Pull request Compare This branch is 97 commits behind chjj:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
LICENSE
README.md
index.js
package.json

README.md

parted

Parted is a streaming multipart parser. It eventually intends to be a completely streaming request body parser for URL encoded messages, JSON, along with multipart. The QS and JSON parsers are currently included, but they're somewhat experimental.

Usage

var parted = require('parted');

var parser = new parted(type, options)
  , parts = {};

parser.on('error', function(err) {
  req.destroy();
  next(err);
});

parser.on('part', function(field, part) {
  // temporary path or string
  parts[field] = part; 
});

parser.on('data', function(bytes) {
  console.log('%d bytes written.', this.written);
});

parser.on('end', function() {
  console.log(parts);
});

req.pipe(parser);

As a middleware

var parser = parted.middleware({ 
  path: __dirname + '/uploads' 
});
app.use(parser);