Skip to content

Commit 10263ab

Browse files
author
Mateusz Mrowiec
committed
Handle 'limit' event when file is over fileSize
1 parent c3c41ec commit 10263ab

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ function processMultipart(options, req, res, next) {
7373
const buffers = [];
7474
let safeFileNameRegex = /[^\w-]/g;
7575

76+
file.on('limit', () => {
77+
res.writeHead(413, {'Connection': 'close'});
78+
res.end('File size limit has been reached');
79+
});
80+
7681
file.on('data', function(data) {
7782
buffers.push(data);
7883

0 commit comments

Comments
 (0)