mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +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
|
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'))
|
||||||
|
|
||||||
filename = force_text(disposition[1]['filename'])
|
|
||||||
|
|
||||||
if 'filename*' in disposition[1]:
|
if 'filename*' in disposition[1]:
|
||||||
filename_encoded = force_text(disposition[1]['filename*'])
|
filename_encoded = force_text(disposition[1]['filename*'])
|
||||||
try:
|
try:
|
||||||
charset, filename_encoded = filename_encoded.split('\'\'', 1)
|
charset, filename_encoded = filename_encoded.split('\'\'', 1)
|
||||||
filename = urlparse.unquote(filename_encoded, charset)
|
filename = urlparse.unquote(filename_encoded)
|
||||||
except (ValueError, LookupError):
|
except (ValueError, LookupError):
|
||||||
pass
|
filename = force_text(disposition[1]['filename'])
|
||||||
|
else:
|
||||||
|
filename = force_text(disposition[1]['filename'])
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user