mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-24 06:18:08 -05:00
Show error message on large image upload
Previously if you attempted to upload a header with file size > 500kB, the operation failed silently and the "uploading" message never went away. Now an error message is displayed saying the image was too large.
This commit is contained in:
@@ -462,9 +462,19 @@ class LimitUploadSize(object):
|
||||
return r(environ, start_response)
|
||||
|
||||
if cl_int > self.max_size:
|
||||
from r2.lib.strings import string_dict
|
||||
error_msg = string_dict['css_validator_messages']['max_size'] % dict(max_size = self.max_size/1024)
|
||||
r = Response()
|
||||
r.status_code = 413
|
||||
r.content = '<html><head></head><body><script type="text/javascript">parent.too_big();</script>request entity too large</body></html>'
|
||||
r.content = ("<html>"
|
||||
"<head>"
|
||||
"<script type='text/javascript'>"
|
||||
"parent.completedUploadImage('failed',"
|
||||
"'',"
|
||||
"'',"
|
||||
"[['BAD_CSS_NAME', ''], ['IMAGE_ERROR', '", error_msg,"']],"
|
||||
"'image-upload');"
|
||||
"</script></head><body>you shouldn\'t be here</body></html>")
|
||||
return r(environ, start_response)
|
||||
|
||||
return self.app(environ, start_response)
|
||||
|
||||
@@ -118,6 +118,7 @@ string_dict = dict(
|
||||
invalid_property = _('"%(cssprop)s" is not a valid CSS property'),
|
||||
invalid_val_for_prop = _('"%(cssvalue)s" is not a valid value for CSS property "%(cssprop)s"'),
|
||||
too_big = _('too big. keep it under %(max_size)dkb'),
|
||||
max_size = _('max size: %(max_size)dkB'),
|
||||
syntax_error = _('syntax error: "%(syntaxerror)s"'),
|
||||
no_imports = _('@imports are not allowed'),
|
||||
invalid_property_list = _('invalid CSS property list "%(proplist)s"'),
|
||||
|
||||
Reference in New Issue
Block a user