Skip to content

Commit

Permalink
Handle 'limit' event when file is over fileSize
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Mrowiec committed Dec 1, 2017
1 parent c3c41ec commit 10263ab
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ function processMultipart(options, req, res, next) {
const buffers = [];
let safeFileNameRegex = /[^\w-]/g;

file.on('limit', () => {
res.writeHead(413, {'Connection': 'close'});
res.end('File size limit has been reached');
});

file.on('data', function(data) {
buffers.push(data);

Expand Down

0 comments on commit 10263ab

Please sign in to comment.