mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
realm: Add maximum file size upload restriction.
This commit adds a restriction to the maximum file size that can be uploaded to a realm based on its plan_type.
This commit is contained in:
committed by
Tim Abbott
parent
808acc9e47
commit
3314c89288
@@ -448,10 +448,11 @@ def upload_file_backend(request: HttpRequest, user_profile: UserProfile) -> Http
|
||||
assert isinstance(user_file, UploadedFile)
|
||||
file_size = user_file.size
|
||||
assert file_size is not None
|
||||
if file_size > settings.MAX_FILE_UPLOAD_SIZE * 1024 * 1024:
|
||||
max_file_upload_size_mebibytes = user_profile.realm.get_max_file_upload_size_mebibytes()
|
||||
if file_size > max_file_upload_size_mebibytes * 1024 * 1024:
|
||||
raise JsonableError(
|
||||
_("Uploaded file is larger than the allowed limit of {max_size} MiB").format(
|
||||
max_size=settings.MAX_FILE_UPLOAD_SIZE,
|
||||
max_size=max_file_upload_size_mebibytes,
|
||||
)
|
||||
)
|
||||
check_upload_within_quota(user_profile.realm, file_size)
|
||||
|
||||
Reference in New Issue
Block a user