{"id":15668668,"url":"https://github.com/yoshuawuyts/multipart-read-stream","last_synced_at":"2025-08-28T12:23:34.853Z","repository":{"id":57305264,"uuid":"71470351","full_name":"yoshuawuyts/multipart-read-stream","owner":"yoshuawuyts","description":"Read a multipart stream over HTTP","archived":false,"fork":false,"pushed_at":"2017-06-21T18:51:42.000Z","size":16,"stargazers_count":13,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-09T11:28:55.335Z","etag":null,"topics":["multipart","node","pez","stream"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yoshuawuyts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-20T14:16:12.000Z","updated_at":"2020-09-03T19:41:41.000Z","dependencies_parsed_at":"2022-09-20T19:26:25.214Z","dependency_job_id":null,"html_url":"https://github.com/yoshuawuyts/multipart-read-stream","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/yoshuawuyts/multipart-read-stream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshuawuyts%2Fmultipart-read-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshuawuyts%2Fmultipart-read-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshuawuyts%2Fmultipart-read-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshuawuyts%2Fmultipart-read-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoshuawuyts","download_url":"https://codeload.github.com/yoshuawuyts/multipart-read-stream/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshuawuyts%2Fmultipart-read-stream/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271746128,"owners_count":24813543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["multipart","node","pez","stream"],"created_at":"2024-10-03T14:13:49.116Z","updated_at":"2025-08-28T12:23:34.822Z","avatar_url":"https://github.com/yoshuawuyts.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# multipart-read-stream [![stability][0]][1]\n[![npm version][2]][3] [![build status][4]][5] [![test coverage][6]][7]\n[![downloads][8]][9] [![js-standard-style][10]][11]\n\nRead a multipart stream over HTTP. Built on top of [pez][pez].\n\n## Usage\n```js\nvar multipart = require('multipart-read-stream')\nvar pump = require('pump')\nvar http = require('http')\n\nhttp.createServer(function (req, res) {\n  var multipartStream = multipart(req.headers, handler)\n\n  pump(req, multipartStream, function (err) {\n    if (err) res.end('server error')\n    res.end()\n  })\n\n  function handler (fieldname, file, filename) {\n    console.log('reading file ' + filename + ' from field ' + fieldname)\n    var fileStream = fs.createWriteStream(path.join('/tmp', filename))\n    pump(file, fileStream)\n  }\n}).listen(8080)\n```\n\n## API\n### readableStream = multipart(headers, [options], fileHandler)\nCreate a new multipart stream handler. Takes the following arguments:\n- __headers:__ an object containing request headers (typically: `req.headers`)\n- __options:__ an object that is passed directly to [pez][pez]\n- __filehandler(fieldname, file, filename, encoding, mimetype):__ handle a\n  file. Each `file` is a `readableStream`\n\n### Events\nmultipart-read-stream returns an instance (from `pez.Dispenser`) which\nemits a number of multipart specific events:\n\n#### readableStream.on('part', cb(stream))\nThe `part` event drives the `fileHandler` callback for the main API.\nThe difference is it supplies a single parameter, the read stream of the\nfile data of a multipart section.\n\n#### readableStream.on('field', cb(name, value))\nA field event is emitted for partitions containing key-value data\n(instead of file data).\n\n#### readableStream.on('preamble', cb(str))\nMultipart data *may* have a preamble section, which is typically\nignored by parsers. However it's sometimes used as an area to\ncontain hints/meta information.\n\n#### readableStream.on('epilogue', cb(str))\nAs with the preamble section, the epilogue section essentially\nhas the same role (ignored, but can be used for meta data), except\nit will be parsed after the body rather than before.\n\n## Installation\n```sh\n$ npm install --save multipart-read-stream\n```\n\n## License\n[MIT](https://tldrlegal.com/license/mit-license)\n\n[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square\n[1]: https://nodejs.org/api/documentation.html#documentation_stability_index\n[2]: https://img.shields.io/npm/v/multipart-read-stream.svg?style=flat-square\n[3]: https://npmjs.org/package/multipart-read-stream\n[4]: https://img.shields.io/travis/yoshuawuyts/multipart-read-stream/master.svg?style=flat-square\n[5]: https://travis-ci.org/yoshuawuyts/multipart-read-stream\n[6]: https://img.shields.io/codecov/c/github/yoshuawuyts/multipart-read-stream/master.svg?style=flat-square\n[7]: https://codecov.io/github/yoshuawuyts/multipart-read-stream\n[8]: http://img.shields.io/npm/dm/multipart-read-stream.svg?style=flat-square\n[9]: https://npmjs.org/package/multipart-read-stream\n[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[11]: https://github.com/feross/standard\n[pez]: https://github.com/hapijs/pez\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoshuawuyts%2Fmultipart-read-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoshuawuyts%2Fmultipart-read-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoshuawuyts%2Fmultipart-read-stream/lists"}