fix: honour max file size in upload file

In case path is /api/method/upload_file, we should honour the max file size
set in system settings and set request max_content_length to that value.
This commit is contained in:
Maharshi Patel 2023-11-21 16:34:26 +05:30
parent b54b6867c4
commit 5af9b294f5

View file

@ -179,9 +179,12 @@ def init_request(request):
raise frappe.SessionStopped("Session Stopped")
else:
frappe.connect(set_admin_as_user=False)
if request.path.startswith("/api/method/upload_file"):
from frappe.core.api.file import get_max_file_size
request.max_content_length = cint(frappe.local.conf.get("max_file_size")) or 10 * 1024 * 1024
request.max_content_length = get_max_file_size()
else:
request.max_content_length = cint(frappe.local.conf.get("max_file_size")) or 10 * 1024 * 1024
make_form_dict(request)
if request.method != "OPTIONS":