-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
FileUploadParser should use more descriptive error when filename not included. #3610
Comments
Do you have a test project we could test against ? |
How are you replicating an issue and exactly what behaviour do you see? |
I just create an test project that reproduce this issue: https://github.com/BraisGabin/drf_3_3_test To reproduce the error just launch the tests with the two different versions |
Do you have the command you use to make the post as well ? |
Thanks to BraisGabin for creating a test project. I am not sure what "command" do you mean? Django command or terminal command... but I cloned the test project and run a CURL command to reproduce the error.
|
I suspect the content type here isn't correct as you're sending a image/jpg instead of a multipart/form Forget about this comment I was thinking about them multipart content. |
According to the spec., the parser is supposed to support direct binary upload. And it works if that line in question (line 181) is fixed from "if file_obj:" to "if file_obj is not None:". |
@yuyou does it work with the change you mention ? I mean do you have a non empty file in the end ? |
@xordoquy yes, confirmed. the CURL script got "HTTP/1.0 200 OK" after I locally made that change and the server received a correct instance of Django UploadedFile (in this case, it is InMemoryUploadedFile object). Tested under |
Hmmm, probably related with #3374. I had made a research in that issue and I had found a problem at the same line. |
@BraisGabin I think it's a bit different the content type seems consistent with sending file. |
A fix to the issue encode#3610
I found to have the same issue. I think the issue results from the implementation of Django's The restframework tests for the parsers are testing these cases and explicitly don't allow uploads without a filename. If you add a filename via the HTTP_CONTENT_DISPOSITION header, it will work. I think the raised ParseError message |
Good digging @gregmuellegger! |
Very good explanation and thanks to @gregmuellegger. I tested with CURL command: and it works. So shall I close this issue? |
Thanks, but no - we still have behavior here we should improve. 😄 |
I did a |
Hi
The FileUploadParser code (line 181) in rest_framework.parsers.py seems to work differently as it should be.
The line does not work in my Python 2.7.8 (OSX El Capitan):
if file_obj:
I modified and works like this:
if file_obj is not None:
Could someone confirm this buggy behavior under other situations?
Thanks.
Regards,
Yu
The text was updated successfully, but these errors were encountered: