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.
This commit is contained in:
Alexander Dutton 2015-01-23 16:14:14 +00:00
parent b07d931261
commit 38ac5bef3f

View File

@ -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")