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}`);
|
||||
// validate that a file was provided
|
||||
const file = files.speech || files.null;
|
||||
logger.debug(file);
|
||||
if (!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');
|
||||
return;
|
||||
}
|
||||
// check if the size is provided (note: some clients may send incorrect content length or leave off content length)
|
||||
logger.debug(headers);
|
||||
if (headers['content-length']) {
|
||||
if (headers['content-length'] > 5000000) {
|
||||
res.status(400).send('Error: only files of 5 megabytes or less are allowed');
|
||||
return;
|
||||
}
|
||||
// check if the size is 5 mb or less
|
||||
if (file.size > 5000000) {
|
||||
res.status(400).send('Error: only files of 5 megabytes or less are allowed');
|
||||
return;
|
||||
}
|
||||
// validate name
|
||||
const name = body.name || file.name.substring(0, file.name.indexOf('.'));
|
||||
|
|
Loading…
Reference in a new issue