1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-11-30 22:41:47 -05:00

Add file size verification in upload script

This commit is contained in:
Jack 2017-10-13 18:07:52 -04:00
parent 589dad32df
commit 907478e6f1
Signed by: foltik
GPG Key ID: 303F88F996E95541

View File

@ -25,7 +25,13 @@ function genFileName() {
router.post('/', dest.single('file'), function(req, res) {
if (req.payload.scope.indexOf('file.upload') === -1) {
res.status(401).json({'message': 'Permission error.'});
res.status(403).json({'message': 'Permission error.'});
return;
}
// Size must be below 128 Megabytes (1024*1024*128 Bytes)
if (req.file.size >= 134217728) {
res.status(413).json({'message': 'File too large.'});
return;
}