Secretly raise the upload limit to 5mb from 4 and send a nice error message if server rejects

This commit is contained in:
Jeremy Zhang 2018-08-17 03:58:08 +00:00
parent 9a1c5945fb
commit a9720fe763
2 changed files with 3 additions and 1 deletions

View File

@ -32,7 +32,7 @@ app.config['SQLALCHEMY_POOL_SIZE'] = 15
app.config['RATELIMIT_STORAGE_URL'] = config["redis-uri"] app.config['RATELIMIT_STORAGE_URL'] = config["redis-uri"]
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=3) app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=3)
app.config['REDIS_URL'] = config["redis-uri"] app.config['REDIS_URL'] = config["redis-uri"]
app.config['MAX_CONTENT_LENGTH'] = 4 * 1024 * 1024 # Limit upload size to 4mb app.config['MAX_CONTENT_LENGTH'] = 5 * 1024 * 1024 # Limit upload size to ~5mb
app.secret_key = config['app-secret'] app.secret_key = config['app-secret']
sentry.init_app(app) sentry.init_app(app)

View File

@ -1868,6 +1868,8 @@
funct.catch(function(data) { funct.catch(function(data) {
if (data.status == 429) { if (data.status == 429) {
Materialize.toast('You are sending messages too fast! 1 message per ' + post_timeout + ' seconds', 10000); Materialize.toast('You are sending messages too fast! 1 message per ' + post_timeout + ' seconds', 10000);
} else if (data.status == 413) {
Materialize.toast('Your file is too powerful! The maximum file size is 4 megabytes.', 5000);
} }
}); });
funct.always(function() { funct.always(function() {