From 3353889ae85cc21890469cf00f7073d1ea5c2070 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 7 May 2013 13:27:27 +0100 Subject: Docs for FileUploadParser --- rest_framework/parsers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'rest_framework') diff --git a/rest_framework/parsers.py b/rest_framework/parsers.py index 27a0db65..614531a1 100644 --- a/rest_framework/parsers.py +++ b/rest_framework/parsers.py @@ -246,7 +246,7 @@ class FileUploadParser(BaseParser): return DataAndFiles(None, {'file': result[1]}) possible_sizes = [x.chunk_size for x in upload_handlers if x.chunk_size] - chunk_size = min([2**31-4] + possible_sizes) + chunk_size = min([2 ** 31 - 4] + possible_sizes) chunks = ChunkIter(stream, chunk_size) counters = [0] * len(upload_handlers) @@ -280,9 +280,10 @@ class FileUploadParser(BaseParser): return parser_context['kwargs']['filename'] except KeyError: pass + try: meta = parser_context['request'].META disposition = parse_header(meta['HTTP_CONTENT_DISPOSITION']) return disposition[1]['filename'] except (AttributeError, KeyError): - pass + raise ParseError("Filename must be set in Content-Disposition header.") -- cgit v1.2.3