MultiPartParser is skipped when uploaded file size > DATA_UPLOAD_MAX_MEMORY_SIZE #7999
Unanswered
eshaan7
asked this question in
Potential Issue
Replies: 1 comment
-
I debug further to pin point the exact lines of code. My findings about the control flow for the file size >
This answers why the parsing is skipped all together but I was unable to pinpoint the role of |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I posted this question on StackOverflow but after much debugging I'm inclined to believe this is a bug.
Original Post:
https://stackoverflow.com/questions/67621576/django-multipartparser-is-skipped-when-uploaded-file-size-data-upload-max-mem
I duplicate the same question here:
I have a view in my DRF app which accepts
Content-type: multipart/form-data
which I use to POST multiple files together,sample
represents a binary filedata
is a string-yfied JSON.Code:
When the
sample
POSTed to this endpoint is < 2.5 mb in size, thetype(request.data)
isdict
whereas if file size > 2.5 mb, thetype(request.data)
is django'sQueryDict
.Logs:
On debugging more, I find out that:
The 2.5mb threshold is the django's DATA_UPLOAD_MAX_MEMORY_SIZE. When I set this variable to a higher value, the threshold becomes exactly that.
the
CustomMultiPartParser
is skipped all-together in the second case. Since the parsing is skipped therequest.data["data"]
is still a string (as can be seen in the logs) which breaks the serialization and the response is:I thought that perhaps the issue is with the
TemporaryUploadedFile
, so in mysettings.py
, I forced it to only useTemporaryUploadFile
with:But I get the same problem with this as well, the
CustomMultiPartParser
is skipped all-together when the file size > 2.5mb (DATA_UPLOAD_MAX_MEMORY_SIZE
).I am not able to understand why the
CustomMultiPartParser
is skipped which breaks the serialization.Beta Was this translation helpful? Give feedback.
All reactions