Socket
Socket
Sign inDemoInstall

multiparty

Package Overview
Dependencies
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multiparty - npm Package Compare versions

Comparing version 3.2.9 to 3.3.0

14

CHANGELOG.md

@@ -0,1 +1,15 @@

### 3.3.0
* Douglas Christopher Wilson (4):
- Expand form.parse in README
- Always emit close after all parts ended
- 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 +16,0 @@

36

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);
});
});

@@ -510,2 +513,7 @@ self.on('field', function(name, value) {

handleFile(self, self.destStream);
} else {
beginFlush(self);
self.destStream.on('end', function(){
endFlush(self);
});
}

@@ -544,5 +552,3 @@ }

if (!self.flushing && self.finished && !self.error) {
process.nextTick(function() {
self.emit('close');
});
self.emit('close');
}

@@ -564,3 +570,2 @@ }

if (self.error) return;
beginFlush(self);
var file = {

@@ -572,2 +577,3 @@ fieldName: fileStream.name,

};
beginFlush(self); // flush to write stream
file.ws = fs.createWriteStream(file.path);

@@ -611,2 +617,6 @@ self.openedFiles.push(file);

});
beginFlush(self); // flush from file stream
fileStream.on('end', function(){
endFlush(self);
});
}

@@ -613,0 +623,0 @@

{
"name": "multiparty",
"version": "3.2.9",
"version": "3.3.0",
"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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc