busboy-promise

0.0.3 • Public • Published

busboy-promise

Promisified multipart collection using Busboy

Usage

npm install busboy-promise

Assume req is a request object. options is an optional object to pass additional options to Busboy.

var busboyPromise = require('busboy-promise');
 
busboyPromise(req, options)
  .then(function (parts) {
    for (var name in parts.fields) {
      var field = parts.fields[name];
      console.log('field name:', field.value, 'value:', field.value);
    }
 
    for (var name in parts.files) {
      var file = parts.files[name];
      console.log('file field name:', file.value);
    }
  })
  .catch(function (err) {
    console.error('error:', err);
  });
 

parts is an object with two properties:

fields: A hashmap of fields. Property names are the field names. Values are objects with the original Busboy event arguments:

{
  value: /* the value */,
  isNameTruncated: /* whether the name is truncated */,
  isValueTruncated: /* whether the value is truncated */,
  encoding: /* the encoding */,
  mimeType: /* the MIME type */
}

files: A hashmap of files. Property names are the field names. Values are object with the original Busboy event arguments:

{
  file: /* the file stream */,
  filename: /* the original filename */,
  encoding: /* the encoding */,
  mimeType: /* the MIME type */
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.3
    739
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.3
    739
  • 0.0.2
    2
  • 0.0.1
    2

Package Sidebar

Install

npm i busboy-promise

Weekly Downloads

9

Version

0.0.3

License

ISC

Last publish

Collaborators

  • atesgoral