JSPM

multipart-form-stream

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q19396F
  • License Apache-2.0

transform files and fields into a multipart/form-data encoded stream

Package Exports

  • multipart-form-stream

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 (multipart-form-stream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

multipart-form-stream

transform files and parameters into a multipart/form-data encoded stream

endorse

Example

var MultipartStream = require('multipart-form-stream')
  , request = require('request')
  , stream
  ;

stream = new MultipartStream({
  boundary: 'customMultipartBoundary' // optional
});

// add a normal field parameter
stream.addField('param1', 'value');

// add a file 
// addFile(field, path, [filename - defaults to filename in path])
stream.addFile('file1', '/path/to/file.png', 'thefile.png');

// add a stream
// addStream(field, filename, mimeType, stream)
stream.addStream('stream1', 'thefilename.png', 'image/png', imagestream);

// do something useful with this stream
// let's pipe it to transloadit!
// make sure you set the Content-Type header
stream.pipe(request.post({
  uri: 'http://api2.transloadit.com/assemblies',
  headers: {
    'Content-Type': 'multipart/form-data; boundary=' + stream.getBoundary()
  }
}));

// enjoy streaming