-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DATA_UPLOAD_MAX_MEMORY_SIZE in Middleware #61
Comments
@AnkurBegining Also, are you sure this is due to the middleware? You can always set |
@jongoncalves |
Hi @AnkurBegining @jongoncalves, we're hitting the same problem. The issue is that The check is here: https://github.com/django/django/blob/master/django/http/request.py#L295 Yes, setting We're currently trying to find a solution, but any ideas would be appreciated! |
As a workaround, you can disable logging only for your file upload views thanks the For example with a django-rest-framework view:
|
My workaround is to override methods in
|
@pchiquet Wrote:
Unfortunately, since the decorator lives on the view, and Middleware is processed prior to passing requests on to views, the @shc261392 Wrote:
This is a more appropriate workaround. To make it more elegant, we can do a simple Content-Length header check against the current maximum file size limit, rather than entirely disable multipart logging. This would allow logging multipart/form-data requests that likely won't trigger the exception, while still avoiding problematic requests:
|
Attaching traceback, for completion RequestDataTooBig:Request body exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE.
File "django/core/handlers/exception.py", line 56, in inner
response = get_response(request)
File "request_logging/middleware.py", line 159, in __call__
cached_request_body = request.body
File "django/http/request.py", line 339, in body
raise RequestDataTooBig( django.core.exceptions.RequestDataTooBig: Request body exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE. |
I don't want to add the DATA_UPLOAD_MAX_MEMORY_SIZE in my settings.py but because of using the middleware. Now response in Django app is directing me that I have exceeded the MAX_MEMORY_SIZE while uploading the files. I don't want to set any max memory size in my app for now. Is there some way to use this middleware and still upload a larger file.
The text was updated successfully, but these errors were encountered: