{"name":"formstream","version":"1.1.1","keywords":["form","stream","multipart","form-data","upload","postfile","request"],"author":{"url":"https://fengmk2.com","name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","_id":"formstream@1.1.1","maintainers":[{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"contributors":[{"url":"https://github.com/fengmk2","name":"fengmk2","email":"fengmk2@gmail.com"},{"url":"https://github.com/xingrz","name":"xingrz","email":"chenxingyu92@gmail.com"}],"homepage":"https://github.com/node-modules/formstream#readme","bugs":{"url":"https://github.com/node-modules/formstream/issues"},"dist":{"shasum":"17259d2440c35ca9736db9f45fb3ba3f8669c750","tarball":"http://registry-npm.ywwl.com/formstream/download/formstream-1.1.1.tgz","fileCount":4,"integrity":"sha512-yHRxt3qLFnhsKAfhReM4w17jP+U1OlhUjnKPPtonwKbIJO7oBP0MvoxkRUwb8AU9n0MIkYy5X5dK6pQnbj+R2Q==","signatures":[{"sig":"MEQCIC9rxLTZTEjQbYNT4opqaZjRneqDpgKcE1JIToEEJZxzAiAqDGNu8OKJBThSuU7InGwkhYO+ysRPXnSlwVW9bBdOdw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15885,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgk041CRA9TVsSAnZWagAAZF4P/1GKeJ3ceLv9HF8gAe6d\neHTYp4VraOXl/UpDe4OXE01ddOD436UqCoFPYYv77GM1y/BPMXFZGxSyXclU\n8HJi978bCWXgNc6aB4OOXr3zTHfGvidrFQSu3YiRTsco2qh02PAKWypj/357\nSEfGcWSPuGJE0ywa9QRqVNpMRQwVrdCevwVc2afKEFrNlAN9g3G3UVHG1TDb\nq+85JpSM5PRbJ5DTnbQDrb6x90Wnl+aeAljrtJuzvnDh3xmyhcte3hd4Bsy1\n/nNO6h9zLdHuae5aCdywXnGdKV+J94CejKy0673v6VPYwW21e2e+TQ7u3jtF\nHJe3YN40CdE/rDSOhMUnrVceI6FgfCL3wbvzKwt9hrOJZBZVw8v12qWuDbuf\npPy5rRq7pdT3zazZB2+Iclhe9gwFB1BF8cVU9E0bnZY4R6s0XBjBpKAq2Igi\n8GxFm9+ZNlsuj6T/lKomO4+om3lGia/xCBigvVlT/dwo+fdSCIlm3RXBNs5u\nwk8hdat3mS/G5UkKbqd1pJOICNpl9jtMHNrisR6115FaElS81LWZEtZiWlaf\nKSHYknwTZUNPZymRKbQHjz7uGqO3QRMsjTTzuwkc94Si4Zx/yYXN43V/hJWa\nfF9QWDZJli/mwLHmVf/tgd64kdRe126g+XcuN8dqnwwWOe+5nFQg3nkSmgC5\nKuXw\r\n=Q5s+\r\n-----END PGP SIGNATURE-----\r\n","size":5477,"noattachment":false,"key":"/formstream/-/formstream-1.1.1.tgz"},"main":"lib/formstream.js","gitHead":"2d5ed81e95b4fde270b5db2720fff0e19effd2dc","scripts":{"test":"mocha -R spec -t 5000 -r should test/*.test.js","autod":"autod -w --prefix '^'","jshint":"jshint .","test-cov":"istanbul cover node_modules/.bin/_mocha -- -t 5000 -r should test/*.test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- -t 5000 -r should test/*.test.js"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"repository":{"url":"git://github.com/node-modules/formstream.git","type":"git"},"_npmVersion":"6.14.12","description":"A multipart/form-data encoded stream, helper for file upload.","directories":{},"_nodeVersion":"12.22.1","dependencies":{"mime":"^2.5.2","destroy":"^1.0.4","pause-stream":"~0.0.11"},"_hasShrinkwrap":false,"devDependencies":{"autod":"*","mocha":"3","should":"4","urllib":"2","express":"^4.16.4","pedding":"1","istanbul":"*","connect-multiparty":"1"},"_npmOperationalInternal":{"tmp":"tmp/formstream_1.1.1_1620266549178_0.7590599209550601","host":"s3://npm-registry-packages"},"readme":"# formstream\n\n[![NPM version][npm-image]][npm-url]\n[![CI](https://github.com/node-modules/formstream/actions/workflows/ci.yml/badge.svg)](https://github.com/node-modules/formstream/actions/workflows/ci.yml)\n[![Test coverage][codecov-image]][codecov-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/formstream.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/formstream\n[codecov-image]: https://codecov.io/github/node-modules/formstream/coverage.svg?branch=master\n[codecov-url]: https://codecov.io/github/node-modules/formstream?branch=master\n[download-image]: https://img.shields.io/npm/dm/formstream.svg?style=flat-square\n[download-url]: https://npmjs.org/package/formstream\n\nA [multipart/form-data](http://tools.ietf.org/html/rfc2388) encoded stream, helper for file upload.\n\n## Install\n\n```bash\nnpm install formstream\n```\n\n## Quick Start\n\n```js\nvar formstream = require('formstream');\nvar http = require('http');\n\nvar form = formstream();\n\n// form.file('file', filepath, filename);\nform.file('file', './logo.png', 'upload-logo.png');\n\n// other form fields\nform.field('foo', 'fengmk2').field('love', 'aerdeng');\n\n// even send file content buffer directly\n// form.buffer(name, buffer, filename, mimeType)\nform.buffer('file2', new Buffer('This is file2 content.'), 'foo.txt');\n\nvar options = {\n  method: 'POST',\n  host: 'upload.cnodejs.net',\n  path: '/store',\n  headers: form.headers()\n};\nvar req = http.request(options, function (res) {\n  console.log('Status: %s', res.statusCode);\n  res.on('data', function (data) {\n    console.log(data.toString());\n  });\n});\n\nform.pipe(req);\n```\n\n### Chaining\n\n```js\nvar fs = require('fs');\nvar formstream = require('formstream');\n\nvar filepath = './logo.png';\nfs.stat(filepath, function (err, stat) {\n  formstream()\n    .field('status', 'share picture')\n    .field('access_token', 'your access token')\n    .file('pic', filepath, 'logo.png', stat.size)\n    .pipe(process.stdout); // your request stream\n});\n```\n\n### Set min chunk buffer size\n\nSome web servers have a limit on the number of chunks, and you can set `minChunkSize` to ensure the size of chunk sent to the server.\n\n```js\nvar fs = require('fs');\nvar FormStream = require('formstream');\n\nvar filepath = './big-file.zip';\nfs.stat(filepath, function (err, stat) {\n  new FormStream({\n    // send >= 2MB chunk buffer size to the server\n    minChunkSize: 1024 * 1024 * 2,\n  }).field('status', 'share file')\n    .field('access_token', 'your access token')\n    .file('file', filepath, 'big-file.zip', stat.size)\n    .pipe(process.stdout); // your request stream\n});\n```\n\n## API Doc\n\n### formstream([options])\n\nCreate a form instance.\n\n#### Arguments\n\n- **options.minChunkSize** Number - min chunk size to emit data event\n\n#### Returns\n\nForm - form instance\n\n### FormStream#field(name, value)\n\nAdd a normal field to the form.\n\n#### Arguments\n\n- **name** String - Name of field\n- **value** String - Value of field\n\n#### Returns\n\nForm - form instance\n\n### FormStream#file(name, filepath[, filename][, filesize])\n\nAdd a local file to be uploaded to the form.\n\n#### Arguments\n\n- **name** String - Name of file field\n- **filepath** String - Local path of the file to be uploaded\n- ***filename*** String - Optional. Name of the file (will be the base name of `filepath` if empty)\n- ***filesize*** Number - Optional. Size of the file (will not generate `Content-Length` header if not specified)\n\n#### Returns\n\nForm - form instance\n\n### FormStream#buffer(name, buffer, filename[, contentType])\n\nAdd a buffer as a file to upload.\n\n#### Arguments\n\n- **name** String - Name of field\n- **buffer** Buffer - The buffer to be uploaded\n- **filename** String - The file name that tells the remote server\n- ***contentType*** String - Optional. Content-Type (aka. MIME Type) of content (will be infered with `filename` if empty)\n\n#### Returns\n\nForm - form instance\n\n### FormStream#stream(name, stream, filename[, contentType][, size])\n\nAdd a readable stream as a file to upload. Event 'error' will be emitted if an error occured.\n\n#### Arguments\n\n- **name** String - Name of field\n- **stream** [stream.Readable](http://nodejs.org/api/stream.html#stream_class_stream_readable) - A readable stream to be piped\n- **filename** String - The file name that tells the remote server\n- ***contentType*** String - Optional. Content-Type (aka. MIME Type) of content (will be infered with `filename` if empty)\n- ***size*** Number - Optional. Size of the stream (will not generate `Content-Length` header if not specified)\n\n#### Returns\n\nForm - form instance\n\n### FormStream#headers([headers])\n\nGet headers for the request.\n\n#### Arguments\n\n- **headers** Object - Additional headers\n\n#### Example\n\n```js\nvar headers = form.headers({\n  'Authorization': 'Bearer kei2akc92jmznvnkeh09sknzdk',\n  'Accept': 'application/vnd.github.v3.full+json'\n});\n```\n\n#### Returns\n\nObject - Headers to be sent.\n\n### Event 'error'\n\nEmitted if there was an error receiving data.\n\n### Event 'data'\n\nThe 'data' event emits when a Buffer was used.\n\nSee [Node.js Documentation](http://nodejs.org/api/stream.html#stream_event_data) for more.\n\n### Event 'end'\n\nEmitted when the stream has received no more 'data' events will happen.\n\nSee [Node.js Documentation](http://nodejs.org/api/stream.html#stream_event_end) for more.\n\n## License\n\n[MIT](LICENSE)\n\n<!-- GITCONTRIBUTOR_START -->\n\n## Contributors\n\n|[<img src=\"https://avatars.githubusercontent.com/u/156269?v=4\" width=\"100px;\"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/288288?v=4\" width=\"100px;\"/><br/><sub><b>xingrz</b></sub>](https://github.com/xingrz)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/32174276?v=4\" width=\"100px;\"/><br/><sub><b>semantic-release-bot</b></sub>](https://github.com/semantic-release-bot)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/13151189?v=4\" width=\"100px;\"/><br/><sub><b>fjc0k</b></sub>](https://github.com/fjc0k)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/18096247?v=4\" width=\"100px;\"/><br/><sub><b>mrspeiser</b></sub>](https://github.com/mrspeiser)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/985607?v=4\" width=\"100px;\"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|\n| :---: | :---: | :---: | :---: | :---: | :---: |\n[<img src=\"https://avatars.githubusercontent.com/u/7326406?v=4\" width=\"100px;\"/><br/><sub><b>shaozj</b></sub>](https://github.com/shaozj)<br/>\n\nThis project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Wed May 15 2024 00:34:12 GMT+0800`.\n\n<!-- GITCONTRIBUTOR_END -->\n","publish_time":1620266549300,"_cnpm_publish_time":1620266549300,"dist-tags":{"latest":"1.5.3"}}