updated server-side 5mb enforcement
This commit is contained in:
parent
33347556fc
commit
ec72307d16
1 changed files with 5 additions and 7 deletions
|
@ -69,18 +69,16 @@ module.exports = app => {
|
||||||
logger.verbose(`POST request on ${originalUrl} from ${ip}`);
|
logger.verbose(`POST request on ${originalUrl} from ${ip}`);
|
||||||
// validate that a file was provided
|
// validate that a file was provided
|
||||||
const file = files.speech || files.null;
|
const file = files.speech || files.null;
|
||||||
|
logger.debug(file);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
postToStats('publish', originalUrl, ip, 'Error: file');
|
postToStats('publish', originalUrl, ip, 'Error: file');
|
||||||
res.status(400).send('Error: No file was submitted or the key used was incorrect. Files posted through this route must use a key of "speech" or null');
|
res.status(400).send('Error: No file was submitted or the key used was incorrect. Files posted through this route must use a key of "speech" or null');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// check if the size is provided (note: some clients may send incorrect content length or leave off content length)
|
// check if the size is 5 mb or less
|
||||||
logger.debug(headers);
|
if (file.size > 5000000) {
|
||||||
if (headers['content-length']) {
|
res.status(400).send('Error: only files of 5 megabytes or less are allowed');
|
||||||
if (headers['content-length'] > 5000000) {
|
return;
|
||||||
res.status(400).send('Error: only files of 5 megabytes or less are allowed');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// validate name
|
// validate name
|
||||||
const name = body.name || file.name.substring(0, file.name.indexOf('.'));
|
const name = body.name || file.name.substring(0, file.name.indexOf('.'));
|
||||||
|
|
Loading…
Reference in a new issue