Skip to content

Commit 0f6cd8a

Browse files
committed
fix: update file upload limit handling to use dictionary access
1 parent a9692ee commit 0f6cd8a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/oss/serializers/file.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ def get_url_content(url, application_id: str):
173173
if not application.file_upload_enable:
174174
return AppApiException(500, _('File upload is not enabled'))
175175
file_limit = 50 * 1024 * 1024
176-
if application.file_upload_setting and application.file_upload_setting.file_limit:
177-
file_limit = application.file_upload_setting.file_limit * 1024 * 1024
176+
if application.file_upload_setting and application.file_upload_setting.get('fileLimit'):
177+
file_limit = application.file_upload_setting.get('fileLimit') * 1024 * 1024
178178
parsed = validate_url(url)
179179

180180
response = requests.get(
@@ -186,7 +186,7 @@ def get_url_content(url, application_id: str):
186186
if is_private_ip(final_host):
187187
raise ValueError("Blocked unsafe redirect to internal host")
188188
# 判断文件大小
189-
if response.headers.get('Content-Length', 0) > file_limit:
189+
if int(response.headers.get('Content-Length', 0)) > file_limit:
190190
return AppApiException(500, _('File size exceeds limit'))
191191
# 返回状态码 响应内容大小 响应的contenttype 还有字节流
192192
content_type = response.headers.get('Content-Type', '')

0 commit comments

Comments
 (0)