mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Removed use encoding available only in py3
This commit is contained in:
parent
644f9b5421
commit
bcca9ed0fd
|
@ -291,15 +291,15 @@ class FileUploadParser(BaseParser):
|
|||
meta = parser_context['request'].META
|
||||
disposition = parse_header(meta['HTTP_CONTENT_DISPOSITION'].encode('utf-8'))
|
||||
|
||||
filename = force_text(disposition[1]['filename'])
|
||||
|
||||
if 'filename*' in disposition[1]:
|
||||
filename_encoded = force_text(disposition[1]['filename*'])
|
||||
try:
|
||||
charset, filename_encoded = filename_encoded.split('\'\'', 1)
|
||||
filename = urlparse.unquote(filename_encoded, charset)
|
||||
filename = urlparse.unquote(filename_encoded)
|
||||
except (ValueError, LookupError):
|
||||
pass
|
||||
filename = force_text(disposition[1]['filename'])
|
||||
else:
|
||||
filename = force_text(disposition[1]['filename'])
|
||||
|
||||
return filename
|
||||
except (AttributeError, KeyError):
|
||||
|
|
Loading…
Reference in New Issue
Block a user