{ "_args": [ [ { "raw": "multiparty@3.3.2", "scope": null, "escapedName": "multiparty", "name": "multiparty", "rawSpec": "3.3.2", "spec": "3.3.2", "type": "version" }, "/home/jdaugherty/work/GT2/GT2-Android/node_modules/connect" ] ], "_from": "multiparty@3.3.2", "_id": "multiparty@3.3.2", "_inCache": true, "_location": "/multiparty", "_npmUser": { "name": "dougwilson", "email": "doug@somethingdoug.com" }, "_npmVersion": "1.4.21", "_phantomChildren": {}, "_requested": { "raw": "multiparty@3.3.2", "scope": null, "escapedName": "multiparty", "name": "multiparty", "rawSpec": "3.3.2", "spec": "3.3.2", "type": "version" }, "_requiredBy": [ "/connect" ], "_resolved": "https://registry.npmjs.org/multiparty/-/multiparty-3.3.2.tgz", "_shasum": "35de6804dc19643e5249f3d3e3bdc6c8ce301d3f", "_shrinkwrap": null, "_spec": "multiparty@3.3.2", "_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/connect", "bugs": { "url": "https://github.com/andrewrk/node-multiparty/issues" }, "dependencies": { "readable-stream": "~1.1.9", "stream-counter": "~0.2.0" }, "description": "multipart/form-data parser which supports streaming", "devDependencies": { "findit": "~2.0.0", "mkdirp": "~0.5.0", "pend": "~1.1.1", "rimraf": "~2.2.8", "superagent": "~0.18.0" }, "directories": {}, "dist": { "shasum": "35de6804dc19643e5249f3d3e3bdc6c8ce301d3f", "tarball": "https://registry.npmjs.org/multiparty/-/multiparty-3.3.2.tgz" }, "engines": { "node": ">=0.8.0" }, "gitHead": "96e1b70c7a9844689f85ba56e1c4437240ae58ea", "homepage": "https://github.com/andrewrk/node-multiparty#readme", "keywords": [ "file", "upload", "formidable", "stream", "s3" ], "license": "MIT", "maintainers": [ { "name": "superjoe", "email": "superjoe30@gmail.com" }, { "name": "dougwilson", "email": "doug@somethingdoug.com" } ], "name": "multiparty", "optionalDependencies": {}, "readme": "# multiparty [![Build Status](https://travis-ci.org/andrewrk/node-multiparty.svg?branch=master)](https://travis-ci.org/andrewrk/node-multiparty) [![NPM version](https://badge.fury.io/js/multiparty.svg)](http://badge.fury.io/js/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 '
'+\n '
'+\n '
'+\n ''+\n '
'\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 * `maxFieldsSize` - 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 * `maxFilesSize` - Only relevant when `autoFiles` is `true`. Limits the\n total bytes accepted for all files combined. If this value is exceeded,\n an `error` event is emitted. The default is `Infinity`.\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.This will cause\n`form` to emit events based off the incoming request.\n\n```js\nvar count = 0;\nvar form = new multiparty.Form();\n\n// Errors may be emitted\nform.on('error', function(err) {\n console.log('Error parsing form: ' + err.stack);\n});\n\n// Parts are emitted when parsing the form\nform.on('part', function(part) {\n // You *must* act on the part by reading it\n // NOTE: if you want to ignore it, just call \"part.resume()\"\n\n if (part.filename === null) {\n // filename is \"null\" when this is a field and not a file\n console.log('got field named ' + part.name);\n // ignore field's content\n part.resume();\n }\n\n if (part.filename !== null) {\n // filename is not \"null\" when this is a file\n count++;\n console.log('got file named ' + part.name);\n // ignore file's content here\n part.resume();\n }\n});\n\n// Close emitted after form parsed\nform.on('close', function() {\n console.log('Upload completed!');\n res.setHeader('text/plain');\n res.end('Received ' + count + ' files');\n});\n\n// Parse req\nform.parse(req);\n\n```\n\nIf `cb` is provided, `autoFields` and `autoFiles` are set to `true` and all\nfields and files are collected and passed to the callback, removing the need to\nlisten to any events on `form`. This is for convenience when wanted to read\neverything, but be careful as this will write all uploaded files to the disk,\neven ones you may not be interested in.\n\n```js\nform.parse(req, function(err, fields, files) {\n Object.keys(fields).forEach(function(name) {\n console.log('got field named ' + name);\n });\n\n Object.keys(files).forEach(function(name) {\n console.log('got file named ' + name);\n });\n\n console.log('Upload completed!');\n res.setHeader('text/plain');\n res.end('Received ' + files.length + ' files');\n});\n```\n\n`fields` is an object where the property names are field names and the values\nare arrays of field values.\n\n`files` is an object where the property names are field names and the values\nare arrays of file objects.\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\nUnless you supply a callback to `form.parse`, you definitely want to handle\nthis event. Otherwise your server *will* crash when users submit bogus\nmultipart requests!\n\nOnly one 'error' event can ever be emitted, and if an 'error' event is\nemitted, then 'close' will not be emitted.\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**The max bytes accepted per request can be specified with `maxFilesSize`.**\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", "repository": { "type": "git", "url": "git+ssh://git@github.com/andrewrk/node-multiparty.git" }, "scripts": { "test": "ulimit -n 500 && node test/test.js" }, "version": "3.3.2" }