Socket
Socket
Sign inDemoInstall

multiparty

Package Overview
Dependencies
6
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.2.9 to 3.2.10

13

CHANGELOG.md

@@ -0,1 +1,14 @@

### 3.2.10
* Douglas Christopher Wilson (4):
- Expand form.parse in README
- Remove execute bit from files
- Fix callback hang in node.js 0.8 on errors
* Andrew Kelley (1):
- tests refactor
* Thanasis Polychronakis (1):
- docs: fix code error in readme
### 3.2.9

@@ -2,0 +15,0 @@

21

index.js

@@ -99,12 +99,15 @@ exports.Form = Form;

if (waitend && req.readable) {
// dump rest of request
req.resume();
req.once('end', function() {
cb(err);
});
return;
}
// wait for req events to fire
process.nextTick(function() {
if (waitend && req.readable) {
// dump rest of request
req.resume();
req.once('end', function() {
cb(err);
});
return;
}
cb(err);
cb(err);
});
});

@@ -111,0 +114,0 @@ self.on('field', function(name, value) {

{
"name": "multiparty",
"version": "3.2.9",
"version": "3.2.10",
"description": "multipart/form-data parser which supports streaming",

@@ -17,11 +17,11 @@ "repository": {

"devDependencies": {
"findit": "0.1.1",
"hashish": "0.0.4",
"mocha": "~1.8.2",
"findit": "~2.0.0",
"mkdirp": "~0.5.0",
"pend": "~1.1.1",
"request": "~2.16.6",
"mkdirp": "~0.3.5",
"superagent": "~0.14.1"
"rimraf": "~2.2.8",
"superagent": "~0.18.0"
},
"scripts": {
"test": "ulimit -n 500 && mocha --timeout 4000 --reporter spec --recursive test/test.js"
"test": "ulimit -n 500 && node test/test.js"
},

@@ -28,0 +28,0 @@ "engines": {

@@ -95,9 +95,66 @@ # 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)

Parses an incoming node.js `request` containing form data. If `cb` is
provided, `autoFields` and `autoFiles` are set to `true` and all fields and
files are collected and passed to the callback:
Parses an incoming node.js `request` containing form data.This will cause
`form` to emit events based off the incoming request.
```js
var count = 0;
var form = new multiparty.Form();
// Errors may be emitted
form.on('error', function(err) {
console.log('Error parsing form: ' + err.stack);
});
// Parts are emitted when parsing the form
form.on('part', function(part) {
// You *must* act on the part by reading it
// NOTE: if you want to ignore it, just call "part.resume()"
if (part.filename === null) {
// filename is "null" when this is a field and not a file
console.log('got field named ' + part.name);
// ignore field's content
part.resume();
}
if (part.filename !== null) {
// filename is not "null" when this is a file
count++;
console.log('got file named ' + part.name);
// ignore file's content here
part.resume();
}
});
// Close emitted after form parsed
form.on('close', function() {
console.log('Upload completed!');
res.setHeader('text/plain');
res.end('Received ' + count + ' files');
});
// Parse req
form.parse(req);
```
If `cb` is provided, `autoFields` and `autoFiles` are set to `true` and all
fields and files are collected and passed to the callback, removing the need to
listen to any events on `form`. This is for convenience when wanted to read
everything, but be careful as this will write all uploaded files to the disk,
even ones you may not be interested in.
```js
form.parse(req, function(err, fields, files) {
// ...
Object.keys(fields).forEach(function(name) {
console.log('got field named ' + name);
});
Object.keys(files).forEach(function(name) {
console.log('got file named ' + name);
});
console.log('Upload completed!');
res.setHeader('text/plain');
res.end('Received ' + files.length + ' files');
});

@@ -104,0 +161,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc