diff options
| author | Tom Christie | 2014-12-12 15:37:43 +0000 | 
|---|---|---|
| committer | Tom Christie | 2014-12-12 15:37:43 +0000 | 
| commit | baaa356489dd51d7c68161db40e99cd59b1124c3 (patch) | |
| tree | 23dc5c4cbe1065580ff88ddd1bfa6dcda956ac68 /rest_framework/parsers.py | |
| parent | 5e6052811716a494e995a84c497579867ee6acaa (diff) | |
| parent | fd473aa905337908b41c9a1087967a19f0558f89 (diff) | |
| download | django-rest-framework-baaa356489dd51d7c68161db40e99cd59b1124c3.tar.bz2 | |
Merge master
Diffstat (limited to 'rest_framework/parsers.py')
| -rw-r--r-- | rest_framework/parsers.py | 16 | 
1 files changed, 9 insertions, 7 deletions
| diff --git a/rest_framework/parsers.py b/rest_framework/parsers.py index 1960e5a8..cb23423d 100644 --- a/rest_framework/parsers.py +++ b/rest_framework/parsers.py @@ -12,7 +12,8 @@ from django.http import QueryDict  from django.http.multipartparser import MultiPartParser as DjangoMultiPartParser  from django.http.multipartparser import MultiPartParserError, parse_header, ChunkIter  from django.utils import six -from rest_framework.compat import force_text, urlparse +from django.utils.six.moves.urllib import parse as urlparse +from django.utils.encoding import force_text  from rest_framework.exceptions import ParseError  from rest_framework import renderers  import json @@ -159,23 +160,24 @@ class FileUploadParser(BaseParser):          chunks = ChunkIter(stream, chunk_size)          counters = [0] * len(upload_handlers) -        for handler in upload_handlers: +        for index, handler in enumerate(upload_handlers):              try:                  handler.new_file(None, filename, content_type,                                   content_length, encoding)              except StopFutureHandlers: +                upload_handlers = upload_handlers[:index + 1]                  break          for chunk in chunks: -            for i, handler in enumerate(upload_handlers): +            for index, handler in enumerate(upload_handlers):                  chunk_length = len(chunk) -                chunk = handler.receive_data_chunk(chunk, counters[i]) -                counters[i] += chunk_length +                chunk = handler.receive_data_chunk(chunk, counters[index]) +                counters[index] += chunk_length                  if chunk is None:                      break -        for i, handler in enumerate(upload_handlers): -            file_obj = handler.file_complete(counters[i]) +        for index, handler in enumerate(upload_handlers): +            file_obj = handler.file_complete(counters[index])              if file_obj:                  return DataAndFiles(None, {'file': file_obj})          raise ParseError("FileUpload parse error - " | 
