Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ function processMultipart(options, req, res, next) {

// Build req.files fields
busboy.on('file', function(fieldname, file, filename, encoding, mime) {
let buf = new Buffer(0);
const buffers = [];
let safeFileNameRegex = /[^\w-]/g;

file.on('data', function(data) {
buf = Buffer.concat([buf, data]);
buffers.push(data);

if (options.debug)
return console.log('Uploading %s -> %s', fieldname, filename);
Expand All @@ -81,6 +81,7 @@ function processMultipart(options, req, res, next) {
if (!req.files)
req.files = {};

const buf = Buffer.concat(buffers);
// see: https://github.com/richardgirges/express-fileupload/issues/14
// firefox uploads empty file in case of cache miss when f5ing page.
// resulting in unexpected behavior. if there is no file data, the file is invalid.
Expand Down