abort uploads over maxfilesize

This commit is contained in:
Danny Coates 2017-07-20 12:50:20 -07:00
parent 34f26fc017
commit 55d3d1a792
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
11 changed files with 415 additions and 2438 deletions

View file

@ -62,7 +62,11 @@ app.use(
}
})
);
app.use(busboy());
app.use(busboy({
limits: {
fileSize: conf.max_file_size
}
}));
app.use(bodyParser.json());
app.use(express.static(STATIC_PATH));
app.use('/l20n', express.static(L20N));
@ -77,6 +81,7 @@ app.get('/jsconfig.js', (req, res) => {
res.render('jsconfig', {
trackerId: conf.analytics_id,
dsn: conf.sentry_id,
maxFileSize: conf.max_file_size,
layout: false
});
});
@ -227,6 +232,12 @@ app.post('/upload', (req, res, next) => {
delete: meta.delete,
id: newId
});
},
err => {
if (err.message === 'limit') {
return res.sendStatus(413);
}
res.sendStatus(500);
});
});