From a9720fe7638b897f2d62b8976c8db7db14747d1b Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Fri, 17 Aug 2018 03:58:08 +0000 Subject: [PATCH] Secretly raise the upload limit to 5mb from 4 and send a nice error message if server rejects --- webapp/titanembeds/app.py | 2 +- webapp/titanembeds/static/js/embed.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/webapp/titanembeds/app.py b/webapp/titanembeds/app.py index 465f2bf..9354662 100644 --- a/webapp/titanembeds/app.py +++ b/webapp/titanembeds/app.py @@ -32,7 +32,7 @@ app.config['SQLALCHEMY_POOL_SIZE'] = 15 app.config['RATELIMIT_STORAGE_URL'] = config["redis-uri"] app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=3) 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'] sentry.init_app(app) diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index 2b25c18..b0d693f 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -1868,6 +1868,8 @@ funct.catch(function(data) { if (data.status == 429) { 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() {