Show routes #72

Merged
bones7242 merged 11 commits from show-routes into master 2017-07-07 03:10:45 +02:00
2 changed files with 14 additions and 0 deletions
Showing only changes of commit 33347556fc - Show all commits

View file

@ -132,6 +132,12 @@ document.getElementById('publish-submit').addEventListener('click', function(eve
}) })
/* socketio-file-upload listeners */ /* socketio-file-upload listeners */
uploader.maxFileSize = 5000000;
uploader.addEventListener("error", function(data){
if (data.code === 1) {
alert("Sorry, uploading is limitted to 5 megabytes.");
}
});
uploader.addEventListener('start', function(event){ uploader.addEventListener('start', function(event){
var name = document.getElementById('publish-name').value; var name = document.getElementById('publish-name').value;
var license = document.getElementById('publish-license').value; var license = document.getElementById('publish-license').value;

View file

@ -74,6 +74,14 @@ module.exports = app => {
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)
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;
}
}
// 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('.'));
const invalidCharacters = /[^A-Za-z0-9,-]/.exec(name); const invalidCharacters = /[^A-Za-z0-9,-]/.exec(name);