All Projects β†’ yoshuawuyts β†’ multipart-read-stream

yoshuawuyts / multipart-read-stream

Licence: MIT license
Read a multipart stream over HTTP

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to multipart-read-stream

meros
πŸͺ’ A fast utility that makes reading multipart responses simple
Stars: ✭ 109 (+738.46%)
Mutual labels:  stream, multipart
RxLoading
RxJava library for showing a loading (i.e. progress bar) state while waiting for async data with minimal effort and advanced options.
Stars: ✭ 49 (+276.92%)
Mutual labels:  stream
tabular-stream
Detects tabular data (spreadsheets, dsv or json, 20+ different formats) and emits normalized objects.
Stars: ✭ 34 (+161.54%)
Mutual labels:  stream
camera.ui
NVR like user Interface for RTSP capable cameras
Stars: ✭ 99 (+661.54%)
Mutual labels:  stream
minotaure
Ce programme permet Γ  des centaines de joueurs de participer Γ  la mΓͺme aventure en votant notamment pour la prochaine action Γ  faire.
Stars: ✭ 48 (+269.23%)
Mutual labels:  stream
conti
minimalistic playout server
Stars: ✭ 23 (+76.92%)
Mutual labels:  stream
files-io
Read many files with node
Stars: ✭ 19 (+46.15%)
Mutual labels:  stream
live-torrent-backend
The backend server for the live-torrent project
Stars: ✭ 38 (+192.31%)
Mutual labels:  stream
binary
Clojure API for binary format I/O using java's stream apis
Stars: ✭ 67 (+415.38%)
Mutual labels:  stream
StreamLinkerino
Twitch.tv client using only StreamLink, MPV, and Chatterino
Stars: ✭ 26 (+100%)
Mutual labels:  stream
ee.Yrewind
Can rewind and save YouTube live stream
Stars: ✭ 133 (+923.08%)
Mutual labels:  stream
RingBuffer
Classic ringbuffer with optional Stream interface
Stars: ✭ 53 (+307.69%)
Mutual labels:  stream
wasm-streams
Bridging between web streams and Rust streams using WebAssembly
Stars: ✭ 61 (+369.23%)
Mutual labels:  stream
hellhound
A set of libraries to create asynchronous, high performance, scalable and simple application.
Stars: ✭ 33 (+153.85%)
Mutual labels:  stream
net-Socket
A minimalist wrapper around System.Net.Sockets.Socket.
Stars: ✭ 21 (+61.54%)
Mutual labels:  stream
RawAnime
Anime app to watch animes without any ads for free. Currently broken.. working to fix it with new UI
Stars: ✭ 19 (+46.15%)
Mutual labels:  stream
unpipe
Unpipe a stream from all destinations
Stars: ✭ 23 (+76.92%)
Mutual labels:  stream
godsend
A simple and eloquent workflow for streaming messages to micro-services.
Stars: ✭ 15 (+15.38%)
Mutual labels:  stream
deep-action-detection
Multi-stream CNN architectures for action detection with actor-centric filtering
Stars: ✭ 24 (+84.62%)
Mutual labels:  stream
node-advanced
Node Advanced Courseware
Stars: ✭ 80 (+515.38%)
Mutual labels:  stream

multipart-read-stream stability

npm version build status test coverage downloads js-standard-style

Read a multipart stream over HTTP. Built on top of pez.

Usage

var multipart = require('multipart-read-stream')
var pump = require('pump')
var http = require('http')

http.createServer(function (req, res) {
  var multipartStream = multipart(req.headers, handler)

  pump(req, multipartStream, function (err) {
    if (err) res.end('server error')
    res.end()
  })

  function handler (fieldname, file, filename) {
    console.log('reading file ' + filename + ' from field ' + fieldname)
    var fileStream = fs.createWriteStream(path.join('/tmp', filename))
    pump(file, fileStream)
  }
}).listen(8080)

API

readableStream = multipart(headers, [options], fileHandler)

Create a new multipart stream handler. Takes the following arguments:

  • headers: an object containing request headers (typically: req.headers)
  • options: an object that is passed directly to pez
  • filehandler(fieldname, file, filename, encoding, mimetype): handle a file. Each file is a readableStream

Events

multipart-read-stream returns an instance (from pez.Dispenser) which emits a number of multipart specific events:

readableStream.on('part', cb(stream))

The part event drives the fileHandler callback for the main API. The difference is it supplies a single parameter, the read stream of the file data of a multipart section.

readableStream.on('field', cb(name, value))

A field event is emitted for partitions containing key-value data (instead of file data).

readableStream.on('preamble', cb(str))

Multipart data may have a preamble section, which is typically ignored by parsers. However it's sometimes used as an area to contain hints/meta information.

readableStream.on('epilogue', cb(str))

As with the preamble section, the epilogue section essentially has the same role (ignored, but can be used for meta data), except it will be parsed after the body rather than before.

Installation

$ npm install --save multipart-read-stream

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].