Merge pull request #692 from imran2140/fix-unicode-s3-key-listing
Fix unicode S3 key listing in Python 2
This commit is contained in:
commit
4d9a0f7dc6
@ -46,6 +46,9 @@ def metadata_from_headers(headers):
|
|||||||
|
|
||||||
|
|
||||||
def clean_key_name(key_name):
|
def clean_key_name(key_name):
|
||||||
|
if six.PY2:
|
||||||
|
return unquote(key_name.encode('utf-8')).decode('utf-8')
|
||||||
|
|
||||||
return unquote(key_name)
|
return unquote(key_name)
|
||||||
|
|
||||||
|
|
||||||
|
@ -846,9 +846,10 @@ def test_unicode_key():
|
|||||||
key = Key(bucket)
|
key = Key(bucket)
|
||||||
key.key = u'こんにちは.jpg'
|
key.key = u'こんにちは.jpg'
|
||||||
key.set_contents_from_string('Hello world!')
|
key.set_contents_from_string('Hello world!')
|
||||||
list(bucket.list())
|
assert [listed_key.key for listed_key in bucket.list()] == [key.key]
|
||||||
key = bucket.get_key(key.key)
|
fetched_key = bucket.get_key(key.key)
|
||||||
assert key.get_contents_as_string().decode("utf-8") == 'Hello world!'
|
assert fetched_key.key == key.key
|
||||||
|
assert fetched_key.get_contents_as_string().decode("utf-8") == 'Hello world!'
|
||||||
|
|
||||||
|
|
||||||
@mock_s3
|
@mock_s3
|
||||||
|
Loading…
Reference in New Issue
Block a user