{
  "name": "multiparty",
  "version": "2.2.0",
  "description": "multipart/form-data parser which supports streaming",
  "repository": {
    "type": "git",
    "url": "git@github.com:superjoe30/node-multiparty.git"
  },
  "keywords": [
    "file",
    "upload",
    "formidable",
    "stream",
    "s3"
  ],
  "devDependencies": {
    "findit": "0.1.1",
    "hashish": "0.0.4",
    "mocha": "~1.8.2",
    "request": "~2.16.6",
    "mkdirp": "~0.3.5",
    "superagent": "~0.14.1"
  },
  "scripts": {
    "test": "ulimit -n 500 && mocha --timeout 4000 --reporter spec --recursive test/test.js"
  },
  "engines": {
    "node": ">=0.8.0"
  },
  "license": "MIT",
  "dependencies": {
    "readable-stream": "~1.1.9",
    "stream-counter": "~0.2.0"
  },
  "readme": "[![Build Status](https://travis-ci.org/superjoe30/node-multiparty.png?branch=master)](https://travis-ci.org/superjoe30/node-multiparty)\n# multiparty\n\nParse http requests with content-type `multipart/form-data`, also known as file uploads.\n\nSee also [busboy](https://github.com/mscdex/busboy) - a\n[faster](https://github.com/mscdex/dicer/wiki/Benchmarks) alternative\nwhich may be worth looking into.\n\n### Why the fork?\n\n * This module uses the Node.js v0.10 streams properly, *even in Node.js v0.8*\n * It will not create a temp file for you unless you want it to.\n * Counts bytes and does math to help you figure out the `Content-Length` of\n   each part.\n * You can easily stream uploads to s3 with\n   [knox](https://github.com/LearnBoost/knox), for [example](examples/s3.js).\n * Less bugs. This code is simpler, has all deprecated functionality removed,\n   has cleaner tests, and does not try to do anything beyond multipart stream\n   parsing.\n\n## Installation\n\n```\nnpm install multiparty\n```\n\n## Usage\n\n * See [examples](examples).\n\nParse an incoming `multipart/form-data` request.\n\n```js\nvar multiparty = require('multiparty')\n  , http = require('http')\n  , util = require('util')\n\nhttp.createServer(function(req, res) {\n  if (req.url === '/upload' && req.method === 'POST') {\n    // parse a file upload\n    var form = new multiparty.Form();\n\n    form.parse(req, function(err, fields, files) {\n      res.writeHead(200, {'content-type': 'text/plain'});\n      res.write('received upload:\\n\\n');\n      res.end(util.inspect({fields: fields, files: files}));\n    });\n\n    return;\n  }\n\n  // show a file upload form\n  res.writeHead(200, {'content-type': 'text/html'});\n  res.end(\n    '<form action=\"/upload\" enctype=\"multipart/form-data\" method=\"post\">'+\n    '<input type=\"text\" name=\"title\"><br>'+\n    '<input type=\"file\" name=\"upload\" multiple=\"multiple\"><br>'+\n    '<input type=\"submit\" value=\"Upload\">'+\n    '</form>'\n  );\n}).listen(8080);\n```\n\n## API\n\n### multiparty.Form\n```js\nvar form = new multiparty.Form(options)\n```\nCreates a new form. Options:\n\n * `encoding` - sets encoding for the incoming form fields. Defaults to `utf8`.\n * `maxFieldSize` - Limits the amount of memory a field (not a file) can\n   allocate in bytes. If this value is exceeded, an `error` event is emitted.\n   The default size is 2MB.\n * `maxFields` - Limits the number of fields that will be parsed before\n   emitting an `error` event. A file counts as a field in this case.\n   Defaults to 1000.\n * `autoFields` - Enables `field` events. This is automatically set to `true`\n   if you add a `field` listener.\n * `autoFiles` - Enables `file` events. This is automatically set to `true`\n   if you add a `file` listener.\n * `uploadDir` - Only relevant when `autoFiles` is `true`. The directory for\n   placing file uploads in. You can move them later using `fs.rename()`.\n   Defaults to `os.tmpDir()`.\n * `hash` - Only relevant when `autoFiles` is `true`. If you want checksums\n   calculated for incoming files, set this to either `sha1` or `md5`.\n   Defaults to off.\n\n#### form.parse(request, [cb])\n\nParses an incoming node.js `request` containing form data. If `cb` is\nprovided, `autoFields` and `autoFiles` are set to `true` and all fields and\nfiles are collected and passed to the callback:\n\n```js\nform.parse(req, function(err, fieldsObject, filesObject, fieldsList, filesList) {\n  // ...\n});\n```\n\nIt is often convenient to access a field or file by name. In this situation,\nuse `fieldsObject` or `filesObject`. However sometimes, as in the case of a\n`<input type=\"file\" multiple=\"multiple\">` the multipart stream will contain\nmultiple files of the same input name, and you are interested in all of them.\nIn this case, use `filesList`.\n\nAnother example is when you do not care what the field name of a file is; you\nare merely interested in a single upload. In this case, set `maxFields` to 1\n(assuming no other fields expected besides the file) and use `filesList[0]`.\n\n#### form.bytesReceived\n\nThe amount of bytes received for this form so far.\n\n#### form.bytesExpected\n\nThe expected number of bytes in this form.\n\n### Events\n\n#### 'error' (err)\n\nYou definitely want to handle this event. If not your server *will* crash when\nusers submit bogus multipart requests!\n\n#### 'part' (part)\n\nEmitted when a part is encountered in the request. `part` is a\n`ReadableStream`. It also has the following properties:\n\n * `headers` - the headers for this part. For example, you may be interested\n   in `content-type`.\n * `name` - the field name for this part\n * `filename` - only if the part is an incoming file\n * `byteOffset` - the byte offset of this part in the request body\n * `byteCount` - assuming that this is the last part in the request,\n   this is the size of this part in bytes. You could use this, for\n   example, to set the `Content-Length` header if uploading to S3.\n   If the part had a `Content-Length` header then that value is used\n   here instead.\n\n#### 'aborted'\n\nEmitted when the request is aborted. This event will be followed shortly\nby an `error` event. In practice you do not need to handle this event.\n\n#### 'progress' (bytesReceived, bytesExpected)\n\n#### 'close'\n\nEmitted after all parts have been parsed and emitted. Not emitted if an `error`\nevent is emitted. This is typically when you would send your response.\n\n#### 'file' (name, file)\n\n**By default multiparty will not touch your hard drive.** But if you add this\nlistener, multiparty automatically sets `form.autoFiles` to `true` and will\nstream uploads to disk for you. \n\n * `name` - the field name for this file\n * `file` - an object with these properties:\n   - `fieldName` - same as `name` - the field name for this file\n   - `originalFilename` - the filename that the user reports for the file\n   - `path` - the absolute path of the uploaded file on disk\n   - `headers` - the HTTP headers that were sent along with this file\n   - `size` - size of the file in bytes\n\nIf you set the `form.hash` option, then `file` will also contain a `hash`\nproperty which is the checksum of the file.\n\n#### 'field' (name, value)\n\n * `name` - field name\n * `value` - string field value\n\n",
  "readmeFilename": "README.md",
  "_id": "multiparty@2.2.0",
  "dist": {
    "shasum": "a7f2341196203083ed0367e4432332bbeb00dfc4"
  },
  "_from": "multiparty@2.2.0",
  "_resolved": "https://registry.npmjs.org/multiparty/-/multiparty-2.2.0.tgz"
}
