Skip to content
This repository was archived by the owner on Sep 16, 2020. It is now read-only.

Commit 67b5a9f

Browse files
committed
updates multipart part handler for node.js v6+ (due to a change on Buffer#write)
1 parent 31d3688 commit 67b5a9f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

multipart-handler.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@
1212
* @ignore
1313
*/
1414
var formidable = require('formidable'), util = require('util');
15+
16+
if (process.version>="v6.0.0") {
17+
var multipart_parser = require('formidable/lib/multipart_parser'),
18+
MultipartParser = multipart_parser.MultipartParser;
19+
MultipartParser.prototype.initWithBoundary = function(str) {
20+
this.boundary = new Buffer(str.length+4);
21+
this.boundary.write('\r\n--', 0, 4 , 'ascii');
22+
this.boundary.write(str, 4, str.length, 'ascii');
23+
this.lookbehind = new Buffer(this.boundary.length+8);
24+
this.state = multipart_parser.START;
25+
this.boundaryChars = {};
26+
for (var i = 0; i < this.boundary.length; i++) {
27+
this.boundaryChars[this.boundary[i]] = true;
28+
}
29+
};
30+
}
31+
1532
function MultipartHandler() {
1633

1734
}

0 commit comments

Comments
 (0)