{"name":"formidable","description":"A node.js module for parsing form data, especially file uploads.","homepage":"https://github.com/felixge/node-formidable","license":"MIT","version":"1.2.3","devDependencies":{"gently":"^0.8.0","findit":"^0.1.2","hashish":"^0.0.4","urun":"^0.0.6","utest":"^0.0.8","request":"^2.11.4"},"directories":{"lib":"./lib"},"publishConfig":{"access":"public","tag":"1.x"},"main":"./lib/index","scripts":{"test":"node test/run.js","clean":"rm test/tmp/*"},"repository":{"type":"git","url":"git://github.com/felixge/node-formidable.git"},"bugs":{"url":"http://github.com/felixge/node-formidable/issues"},"optionalDependencies":{},"readme":"# Formidable\r\n\r\n## Purpose\r\n\r\nA Node.js module for parsing form data, especially file uploads.\r\n\r\n\r\n## Changelog\r\n\r\n[./CHANGELOG.md](https://github.com/node-formidable/formidable/blob/master/CHANGELOG.md)\r\n\r\n## Current status\r\n\r\n**Maintainers Wanted:** Please see https://github.com/felixge/node-formidable/issues/412\r\n\r\nThis module was developed for [Transloadit](http://transloadit.com/), a service focused on uploading\r\nand encoding images and videos. It has been battle-tested against hundreds of GB of file uploads from\r\na large variety of clients and is considered production-ready.\r\n\r\n## Features\r\n\r\n* Fast (~500mb/sec), non-buffering multipart parser\r\n* Automatically writing file uploads to disk\r\n* Low memory footprint\r\n* Graceful error handling\r\n* Very high test coverage\r\n\r\n## Installation\r\n\r\n```sh\r\nnpm install formidable@1.x\r\n# or the canary version\r\nnpm install formidable@canary\r\n## 3.x\r\nnpm install formidable@3.x\r\n```\r\n\r\nThis is a low-level package, and if you're using a high-level framework it may already be included. However, [Express v4](http://expressjs.com) does not include any multipart handling, nor does [body-parser](https://github.com/expressjs/body-parser).\r\n\r\nNote: Formidable requires [gently](http://github.com/felixge/node-gently) to run the unit tests, but you won't need it for just using the library.\r\n\r\n## Example\r\n\r\nParse an incoming file upload.\r\n```javascript\r\nvar formidable = require('formidable'),\r\n    http = require('http'),\r\n    util = require('util');\r\n\r\nhttp.createServer(function(req, res) {\r\n  if (req.url == '/upload' && req.method.toLowerCase() == 'post') {\r\n    // parse a file upload\r\n    var form = new formidable.IncomingForm();\r\n\r\n    form.parse(req, function(err, fields, files) {\r\n      res.writeHead(200, {'content-type': 'text/plain'});\r\n      res.write('received upload:\\n\\n');\r\n      res.end(util.inspect({fields: fields, files: files}));\r\n    });\r\n\r\n    return;\r\n  }\r\n\r\n  // show a file upload form\r\n  res.writeHead(200, {'content-type': 'text/html'});\r\n  res.end(\r\n    '<form action=\"/upload\" enctype=\"multipart/form-data\" method=\"post\">'+\r\n    '<input type=\"text\" name=\"title\"><br>'+\r\n    '<input type=\"file\" name=\"upload\" multiple=\"multiple\"><br>'+\r\n    '<input type=\"submit\" value=\"Upload\">'+\r\n    '</form>'\r\n  );\r\n}).listen(8080);\r\n```\r\n## API\r\n\r\n### Formidable.IncomingForm\r\n```javascript\r\nvar form = new formidable.IncomingForm()\r\n```\r\nCreates a new incoming form.\r\n\r\n```javascript\r\nform.encoding = 'utf-8';\r\n```\r\nSets encoding for incoming form fields.\r\n\r\n```javascript\r\nform.uploadDir = \"/my/dir\";\r\n```\r\nSets the directory for placing file uploads in. You can move them later on using\r\n`fs.rename()`. The default is `os.tmpdir()`.\r\n\r\n```javascript\r\nform.keepExtensions = false;\r\n```\r\nIf you want the files written to `form.uploadDir` to include the extensions of the original files, set this property to `true`.\r\n\r\n```javascript\r\nform.type\r\n```\r\nEither 'multipart' or 'urlencoded' depending on the incoming request.\r\n\r\n```javascript\r\nform.maxFieldsSize = 20 * 1024 * 1024;\r\n```\r\nLimits the amount of memory all fields together (except files) can allocate in bytes.\r\nIf this value is exceeded, an `'error'` event is emitted. The default\r\nsize is 20MB.\r\n\r\n```javascript\r\nform.maxFileSize = 200 * 1024 * 1024;\r\n```\r\nLimits the size of uploaded file.\r\nIf this value is exceeded, an `'error'` event is emitted. The default\r\nsize is 200MB.\r\n\r\n```javascript\r\nform.maxFields = 1000;\r\n```\r\nLimits the number of fields that the querystring parser will decode. Defaults\r\nto 1000 (0 for unlimited).\r\n\r\n```javascript\r\nform.hash = false;\r\n```\r\nIf you want checksums calculated for incoming files, set this to either `'sha1'` or `'md5'`.\r\n\r\n```javascript\r\nform.multiples = false;\r\n```\r\nIf this option is enabled, when you call `form.parse`, the `files` argument will contain arrays of files for inputs which submit multiple files using the HTML5 `multiple` attribute.\r\n\r\n```javascript\r\nform.bytesReceived\r\n```\r\nThe amount of bytes received for this form so far.\r\n\r\n```javascript\r\nform.bytesExpected\r\n```\r\nThe expected number of bytes in this form.\r\n\r\n```javascript\r\nform.parse(request, [cb]);\r\n```\r\nParses an incoming node.js `request` containing form data. If `cb` is provided, all fields and files are collected and passed to the callback:\r\n\r\n\r\n```javascript\r\nform.parse(req, function(err, fields, files) {\r\n  // ...\r\n});\r\n\r\nform.onPart(part);\r\n```\r\nYou may overwrite this method if you are interested in directly accessing the multipart stream. Doing so will disable any `'field'` / `'file'` events  processing which would occur otherwise, making you fully responsible for handling the processing.\r\n\r\n```javascript\r\nform.onPart = function(part) {\r\n  part.addListener('data', function() {\r\n    // ...\r\n  });\r\n}\r\n```\r\nIf you want to use formidable to only handle certain parts for you, you can do so:\r\n```javascript\r\nform.onPart = function(part) {\r\n  if (!part.filename) {\r\n    // let formidable handle all non-file parts\r\n    form.handlePart(part);\r\n  }\r\n}\r\n```\r\nCheck the code in this method for further inspiration.\r\n\r\n\r\n### Formidable.File\r\n```javascript\r\nfile.size = 0\r\n```\r\nThe size of the uploaded file in bytes. If the file is still being uploaded (see `'fileBegin'` event), this property says how many bytes of the file have been written to disk yet.\r\n```javascript\r\nfile.path = null\r\n```\r\nThe path this file is being written to. You can modify this in the `'fileBegin'` event in\r\ncase you are unhappy with the way formidable generates a temporary path for your files.\r\n```javascript\r\nfile.name = null\r\n```\r\nThe name this file had according to the uploading client.\r\n```javascript\r\nfile.type = null\r\n```\r\nThe mime type of this file, according to the uploading client.\r\n```javascript\r\nfile.lastModifiedDate = null\r\n```\r\nA date object (or `null`) containing the time this file was last written to. Mostly\r\nhere for compatibility with the [W3C File API Draft](http://dev.w3.org/2006/webapi/FileAPI/).\r\n```javascript\r\nfile.hash = null\r\n```\r\nIf hash calculation was set, you can read the hex digest out of this var.\r\n\r\n#### Formidable.File#toJSON()\r\n\r\n  This method returns a JSON-representation of the file, allowing you to\r\n  `JSON.stringify()` the file which is useful for logging and responding\r\n  to requests.\r\n\r\n### Events\r\n\r\n\r\n#### 'progress'\r\n\r\nEmitted after each incoming chunk of data that has been parsed. Can be used to roll your own progress bar.\r\n\r\n```javascript\r\nform.on('progress', function(bytesReceived, bytesExpected) {\r\n});\r\n```\r\n\r\n\r\n\r\n#### 'field'\r\n\r\nEmitted whenever a field / value pair has been received.\r\n\r\n```javascript\r\nform.on('field', function(name, value) {\r\n});\r\n```\r\n\r\n#### 'fileBegin'\r\n\r\nEmitted whenever a new file is detected in the upload stream. Use this event if\r\nyou want to stream the file to somewhere else while buffering the upload on\r\nthe file system.\r\n\r\n```javascript\r\nform.on('fileBegin', function(name, file) {\r\n});\r\n```\r\n\r\n#### 'file'\r\n\r\nEmitted whenever a field / file pair has been received. `file` is an instance of `File`.\r\n\r\n```javascript\r\nform.on('file', function(name, file) {\r\n});\r\n```\r\n\r\n#### 'error'\r\n\r\nEmitted when there is an error processing the incoming form. A request that experiences an error is automatically paused, you will have to manually call `request.resume()` if you want the request to continue firing `'data'` events.\r\n\r\n```javascript\r\nform.on('error', function(err) {\r\n});\r\n```\r\n\r\n#### 'aborted'\r\n\r\n\r\nEmitted when the request was aborted by the user. Right now this can be due to a 'timeout' or 'close' event on the socket. After this event is emitted, an `error` event will follow. In the future there will be a separate 'timeout' event (needs a change in the node core).\r\n```javascript\r\nform.on('aborted', function() {\r\n});\r\n```\r\n\r\n##### 'end'\r\n```javascript\r\nform.on('end', function() {\r\n});\r\n```\r\nEmitted when the entire request has been received, and all contained files have finished flushing to disk. This is a great place for you to send your response.\r\n\r\n\r\n\r\n## Changelog\r\n\r\n### v1.1.1 (2017-01-15)\r\n\r\n * Fix DeprecationWarning about os.tmpDir() (Christian)\r\n * Update `buffer.write` order of arguments for Node 7 (Kornel Lesiński)\r\n * JSON Parser emits error events to the IncomingForm (alessio.montagnani)\r\n * Improved Content-Disposition parsing (Sebastien)\r\n * Access WriteStream of fs during runtime instead of include time (Jonas Amundsen)\r\n * Use built-in toString to convert buffer to hex (Charmander)\r\n * Add hash to json if present (Nick Stamas)\r\n * Add license to package.json (Simen Bekkhus)\r\n\r\n### v1.0.14 (2013-05-03)\r\n\r\n* Add failing hash tests. (Ben Trask)\r\n* Enable hash calculation again (Eugene Girshov)\r\n* Test for immediate data events (Tim Smart)\r\n* Re-arrange IncomingForm#parse (Tim Smart)\r\n\r\n### v1.0.13\r\n\r\n* Only update hash if update method exists (Sven Lito)\r\n* According to travis v0.10 needs to go quoted (Sven Lito)\r\n* Bumping build node versions (Sven Lito)\r\n* Additional fix for empty requests (Eugene Girshov)\r\n* Change the default to 1000, to match the new Node behaviour. (OrangeDog)\r\n* Add ability to control maxKeys in the querystring parser. (OrangeDog)\r\n* Adjust test case to work with node 0.9.x (Eugene Girshov)\r\n* Update package.json (Sven Lito)\r\n* Path adjustment according to eb4468b (Markus Ast)\r\n\r\n### v1.0.12\r\n\r\n* Emit error on aborted connections (Eugene Girshov)\r\n* Add support for empty requests (Eugene Girshov)\r\n* Fix name/filename handling in Content-Disposition (jesperp)\r\n* Tolerate malformed closing boundary in multipart (Eugene Girshov)\r\n* Ignore preamble in multipart messages (Eugene Girshov)\r\n* Add support for application/json (Mike Frey, Carlos Rodriguez)\r\n* Add support for Base64 encoding (Elmer Bulthuis)\r\n* Add File#toJSON (TJ Holowaychuk)\r\n* Remove support for Node.js 0.4 & 0.6 (Andrew Kelley)\r\n* Documentation improvements (Sven Lito, Andre Azevedo)\r\n* Add support for application/octet-stream (Ion Lupascu, Chris Scribner)\r\n* Use os.tmpdir() to get tmp directory (Andrew Kelley)\r\n* Improve package.json (Andrew Kelley, Sven Lito)\r\n* Fix benchmark script (Andrew Kelley)\r\n* Fix scope issue in incoming_forms (Sven Lito)\r\n* Fix file handle leak on error (OrangeDog)\r\n\r\n## License\r\n\r\nFormidable is licensed under the MIT license.\r\n\r\n## Ports\r\n\r\n* [multipart-parser](http://github.com/FooBarWidget/multipart-parser): a C++ parser based on formidable\r\n\r\n## Credits\r\n\r\n* [Ryan Dahl](http://twitter.com/ryah) for his work on [http-parser](http://github.com/ry/http-parser) which heavily inspired multipart_parser.js\r\n","readmeFilename":"Readme.md","gitHead":"04a3a4900b2ca483a0f2654e550fec69f23536d6","dependencies":{},"_id":"formidable@1.2.3","_nodeVersion":"16.11.0","_npmVersion":"8.0.0","dist":{"integrity":"sha512-YtVk/NESNJz0jAdUVI6nEoMfw6bv3hxGFQRlXRJXzdpxbomEo32YAhn8OwA3ncDaBQ4Tcxh/NkVy9lB5paYEXQ==","shasum":"27cfbd60b54d2ac518c848f40ea354d081e4d34d","tarball":"http://registry-npm.ywwl.com/formidable/download/formidable-1.2.3.tgz","fileCount":11,"unpackedSize":39564,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHGkpU9IkX2XHwtw3waHRXuBTZWeZwSaYaX7+qo18CU3AiBj4HqO9WTQQQETe5olk+S0DyPzypAxjrLap/zGZfYCIQ=="}],"size":11731,"noattachment":false,"key":"/formidable/-/formidable-1.2.3.tgz"},"_npmUser":{"name":"grossacasacs","email":"cyril.walle@protonmail.com"},"maintainers":[{"name":"felixge","email":"felix@debuggable.com"},{"name":"kornel","email":"npmspam@geekhood.net"},{"name":"grossacasacs","email":"cyril.walle@protonmail.com"},{"name":"tunnckocore","email":"dev@tunnckocore.anonaddy.com"},{"name":"quantumsheep","email":"nathanael.dmc@outlook.fr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/formidable_1.2.3_1635598690879_0.5534542505857727"},"_hasShrinkwrap":false,"deprecated":"Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau","publish_time":1635598691023,"_cnpm_publish_time":1635598691023,"dist-tags":{"latest":"3.5.4","legacy":"1.2.6","next":"4.0.0-rc.6","v1":"1.2.6","v2-latest":"2.1.5"}}