Show routes #72

Merged
bones7242 merged 11 commits from show-routes into master 2017-07-07 03:10:45 +02:00
Showing only changes of commit ec72307d16 - Show all commits

View file

@ -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('.'));