Merge pull request #1530 from vlastv/patch-3

Fixed return type
This commit is contained in:
Xavier Ordoquy 2014-04-14 11:33:08 +02:00
commit b3b0515ae6
2 changed files with 3 additions and 3 deletions

View File

@ -10,7 +10,7 @@ from django.core.files.uploadhandler import StopFutureHandlers
from django.http import QueryDict from django.http import QueryDict
from django.http.multipartparser import MultiPartParser as DjangoMultiPartParser from django.http.multipartparser import MultiPartParser as DjangoMultiPartParser
from django.http.multipartparser import MultiPartParserError, parse_header, ChunkIter from django.http.multipartparser import MultiPartParserError, parse_header, ChunkIter
from rest_framework.compat import etree, six, yaml from rest_framework.compat import etree, six, yaml, force_text
from rest_framework.exceptions import ParseError from rest_framework.exceptions import ParseError
from rest_framework import renderers from rest_framework import renderers
import json import json
@ -289,6 +289,6 @@ class FileUploadParser(BaseParser):
try: try:
meta = parser_context['request'].META meta = parser_context['request'].META
disposition = parse_header(meta['HTTP_CONTENT_DISPOSITION'].encode('utf-8')) disposition = parse_header(meta['HTTP_CONTENT_DISPOSITION'].encode('utf-8'))
return disposition[1]['filename'] return force_text(disposition[1]['filename'])
except (AttributeError, KeyError): except (AttributeError, KeyError):
pass pass

View File

@ -112,4 +112,4 @@ class TestFileUploadParser(TestCase):
def test_get_filename(self): def test_get_filename(self):
parser = FileUploadParser() parser = FileUploadParser()
filename = parser.get_filename(self.stream, None, self.parser_context) filename = parser.get_filename(self.stream, None, self.parser_context)
self.assertEqual(filename, 'file.txt'.encode('utf-8')) self.assertEqual(filename, 'file.txt')