{"id":20448072,"url":"https://github.com/xingrz/multipartist","last_synced_at":"2025-04-13T01:13:38.970Z","repository":{"id":10607905,"uuid":"12825050","full_name":"xingrz/multipartist","owner":"xingrz","description":"A library to build multipart data, with streaming APIs.","archived":false,"fork":false,"pushed_at":"2017-12-05T05:48:07.000Z","size":54,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T01:13:35.189Z","etag":null,"topics":["multipart","multipart-formdata","multipart-related","nodejs"],"latest_commit_sha":null,"homepage":"","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/xingrz.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":"2013-09-14T05:53:36.000Z","updated_at":"2022-06-23T08:47:08.000Z","dependencies_parsed_at":"2022-09-20T20:00:36.076Z","dependency_job_id":null,"html_url":"https://github.com/xingrz/multipartist","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xingrz%2Fmultipartist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xingrz%2Fmultipartist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xingrz%2Fmultipartist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xingrz%2Fmultipartist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xingrz","download_url":"https://codeload.github.com/xingrz/multipartist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650754,"owners_count":21139681,"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","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","multipart-formdata","multipart-related","nodejs"],"created_at":"2024-11-15T10:32:16.806Z","updated_at":"2025-04-13T01:13:38.952Z","avatar_url":"https://github.com/xingrz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Multipartist\n==========\n\n[![][travis-img]][travis-url] [![][coveralls-img]][coveralls-url] [![][npm-version]][npm-url] [![][npm-downloads]][npm-url] [![][license-img]][license-url] [![][issues-img]][issues-url]\n\nBuild multipart stream, with stream.\n\nUnlike [form-data](https://github.com/form-data/form-data), this library provides more lower-level APIs to build not only `multipart/form-data` but also `multipart/related` and any other similar structures.\n\n## Requirements\n\nNode \u003e= 4, tested on latest Node and latest LTS Node.\n\n## Installation\n\n```sh\nnpm install --save multipartist\n```\n\n## Usage\n\n```js\nimport Multipart from 'multipartist';\nimport request from 'request';\nimport { createReadStream } from 'fs';\n\nconst multipart = new Multipart('form-data');\n\nmultipart.append(JSON.stringify({ 'text': 'Hello world!' }), {\n  'Content-Disposition': 'form-data; name=\"metadata\"',\n  'Content-Type': 'application/json; charset=UTF-8',\n});\n\nmultipart.append(createReadStream('audio.wav'), {\n  'Content-Disposition': 'form-data; name=\"audio\"',\n  'Content-Type': 'application/octet-stream',\n  'X-Speaker-Name': 'XiNGRZ',\n});\n\nmultipart.pipe(request.post('https://api.example.com/recognize', {\n  headers: multipart.headers({\n    'Authorization': 'Bearer YOUR_OWN_API_KEY_HERE',\n  }),\n}, (req, res, body) =\u003e {\n  // ...\n}));\n```\n\n## API\n\n### Class: Multipartist(type[, options])\n\nThe Multipartist class, which is an subclass of [Readable Stream](https://nodejs.org/dist/latest/docs/api/stream.html#stream_readable_streams).\n\n#### Arguments\n\n- **type** String - Multipart type (e.g. `form-data`, `related`, etc...). Defaults to `form-data`.\n- ***options*** Object\n    - ***endOnEmpty=true*** - Whether the Multipartist readable should end when it's empty. Otherwise, it won't end until explicitly call `flush()`\n\n### Multipartist#append(content[, length][, headers])\n\nAdd a part.\n\n#### Arguments\n\n- **content** String | Buffer | [Readable](https://nodejs.org/dist/latest/docs/api/stream.html#stream_class_stream_readable) - Content of this part\n- ***length*** Number - Optional. Length of the content of this part. It's better to specific the length of a `Readable` part explicitly. Otherwise, the `Content-Length` of the whole multipart payload would not be caculated.\n- ***headers*** Object - Optional. Additional headers of this part\n\n#### Returns\n\nMultipartist - the Multipartist instance itself\n\n### Multipartist#headers([additions])\n\nReturns all auto-generated headers.\n\n#### Arguments\n\n- ***headers*** Object - Optional. Additional headers\n\n#### Returns\n\n- Object - Headers\n\n### Multipartist#flush()\n\nFlush the ending data and end the stream. Only required if `endOnEmpty` is explicitly set to `false`.\n\n## Test\n\n```sh\nnpm test\n```\n\n## License\n\nThis project is released under the terms of [MIT License](LICENSE).\n\n\n[travis-img]: https://img.shields.io/travis/xingrz/multipartist/master.svg?style=flat-square\n[travis-url]: https://travis-ci.org/xingrz/multipartist\n[coveralls-img]: https://img.shields.io/coveralls/xingrz/multipartist/master.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/xingrz/multipartist\n[npm-version]: https://img.shields.io/npm/v/multipartist.svg?style=flat-square\n[npm-downloads]: https://img.shields.io/npm/dm/multipartist.svg?style=flat-square\n[npm-url]: https://www.npmjs.org/package/multipartist\n[license-img]: https://img.shields.io/npm/l/multipartist.svg?style=flat-square\n[license-url]: LICENSE\n[issues-img]: https://img.shields.io/github/issues/xingrz/multipartist.svg?style=flat-square\n[issues-url]: https://github.com/xingrz/multipartist/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxingrz%2Fmultipartist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxingrz%2Fmultipartist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxingrz%2Fmultipartist/lists"}