An open API service indexing awesome lists of open source software.

https://github.com/tim-smart/node-multipart

Multipart stream encoder for node.js
https://github.com/tim-smart/node-multipart

Last synced: 9 months ago
JSON representation

Multipart stream encoder for node.js

Awesome Lists containing this project

README

          

node-multipart
==============

A simple multipart message creation utility for Node.js, that has a nice stream-like interface.

Install
-------

npm install multipart

Usage
-----

For a brief introduction to the api, take a look at test/simple.js. Otherwise:

var multipart = require('multipart')

// Create the stream object using the provided factory.
var my_mp_stream = multipart.createMultipartStream()

// Pipe the multipart message to stdout.
my_mp_stream.pipe(process.stdout)

// Write some stuff to the multipart stream. Take a look in test/ and index.js
// for more options and gimmicks.
my_mp_stream.write(
{ 'Content-Disposition' : 'form-data; name="files"'
, 'Content-Type' : another_mp_stream.contentType(my_mp_stream)
}
, another_mp_stream
, function () {
console.log('FILESWRITTEN')
}
)

// Tie up the loose ends.
my_mp_stream.end(end_cb_fn)