restify-multipart-body-parser

0.1.1 • Public • Published

restify-multipart-body-parser

Configurable multipart body parser (based on busboy) middleware for restify.

Configuration

{
  auto: { // Automatic parsing
    fields: true
  },
  multipart: true, // Multipart content parsing
  urlencoded: true, // Urlencoded content parsing
  encoding: 'utf8', // Default encoding
 
  // Parser limits (busboy)
  limits: {
    fieldNameSize: 100, // Max field name size (Default: 100 bytes).
    fieldSize: 1024 * 1024, // Max field value size (Default: 1MB)
    fields: undefined, // Max number of non-file fields (Default: Infinity).
    fileSize: undefined, // For multipart forms, the max file size (Default: Infinity).
    files: undefined, // For multipart forms, the max number of file fields (Default: Infinity).
    parts: undefined, // For multipart forms, the max number of parts (fields + files) (Default: Infinity).
    headerPairs: 100 // For multipart forms, the max number of header key=>value pairs to parse Default: 2000 (same as node's http).
  }
}

Usage

server.put('/multipart', function (req, res, next) {
  req.on('fields', function onFields (fields) {
    // Or req.params
  });
 
  req.on('file', function onFile (field, file, filename, encoding, mimetype) {
    // Directly proxied from busboy
  });
 
  req.on('finish', function onFinish () {
    // Finished
  })
});

TODO

  • Switch from busboy to custom parser (to lightly abstracted dicer based parser?)
  • Automatic files parsing and saving to the local filesystem

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.1
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.1
    2
  • 0.1.0
    0

Package Sidebar

Install

npm i restify-multipart-body-parser

Weekly Downloads

2

Version

0.1.1

License

MIT

Last publish

Collaborators

  • harrisiirak