Skip to content

Commit

Permalink
Moved issue richardgirges#14 check to fileFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanBurunkov authored Mar 27, 2019
1 parent acf0f8e commit 0179b84
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/processMultipart.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,11 @@ module.exports = (options, req, res, next) => {
file.on('data', dataHandler);

file.on('end', () => {
const buffer = complete(filename);
// 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.
if (!buffer.length && !options.useTempFiles) {
return;
}

// Add file instance to the req.files
req.files = buildFields(req.files, fieldname, fileFactory(
{
buffer: complete(),
name: parseFileName(options, filename),
buffer,
tempFilePath: getFilePath(),
size: getFileSize(),
hash: getHash(),
Expand All @@ -69,7 +61,7 @@ module.exports = (options, req, res, next) => {
options
));
});

file.on('error', cleanup, next);
});

Expand Down

0 comments on commit 0179b84

Please sign in to comment.