Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tootallnate/node-multipart-stack
A `StreamStack` subclass that parses "multipart" data, often from SMTP or HTTP.
https://github.com/tootallnate/node-multipart-stack
Last synced: 5 days ago
JSON representation
A `StreamStack` subclass that parses "multipart" data, often from SMTP or HTTP.
- Host: GitHub
- URL: https://github.com/tootallnate/node-multipart-stack
- Owner: TooTallNate
- Created: 2011-03-22T20:17:16.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2011-11-07T22:00:43.000Z (about 13 years ago)
- Last Synced: 2024-12-10T14:03:41.810Z (17 days ago)
- Language: JavaScript
- Homepage:
- Size: 113 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
node-multipart-stack
====================
### A `StreamStack` subclass that parses "multipart" data, often from SMTP or HTTP.This module implements [Section 7.2 of RFC 1341][rfc1341]. It can be easily used
in conjunction with any node `ReadableStream`.Usage
-----Here's a simple HTTP server that can parse multipart requests, like from an HTML
multipart form.``` javascript
var http = require('http');
var multipart = require('multipart-stack');var server = http.createServer(function(req, res) {
// includes a built-in "Content-Type Parser"
var parsed = multipart.parseContentType(req.headers['content-type']);if (parsed.type === 'multipart') {
var parser = new multipart.Parser(req, parsed.boundary);// A 'part' event gets fired once per individual "part" of the multipart body
parser.on('part', function (part) {
// the 'part' arg is a `ReadableStream` that also emits a 'headers' event.
part.on('headers', function(headers) {
console.log(headers);
});
part.pipe(process.stdout, { end: false });
});
} else {
// non-file-upload logic
}});
```[Node]: http://nodejs.org
[rfc1341]: http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html