From 38ac5bef3f6dfde98c34f607da0ab806cb67225f Mon Sep 17 00:00:00 2001 From: Alexander Dutton Date: Fri, 23 Jan 2015 16:14:14 +0000 Subject: [PATCH] Improve test of whether file was parsed successfully. bool(file) is True iff file.filename is non-empty, so if there's no filename associated (e.g. no content-disposition) it wouldn't otherwise detect that a file upload handler successfully handled a file. --- rest_framework/parsers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/parsers.py b/rest_framework/parsers.py index ef72677ce..a82aa7459 100644 --- a/rest_framework/parsers.py +++ b/rest_framework/parsers.py @@ -276,7 +276,7 @@ class FileUploadParser(BaseParser): for index, handler in enumerate(upload_handlers): file_obj = handler.file_complete(counters[index]) - if file_obj: + if file_obj is not None: return DataAndFiles({}, {'file': file_obj}) raise ParseError("FileUpload parse error - " "none of upload handlers can handle the stream")