s3 key_name encoding should be variable (#5184)

This commit is contained in:
Cristopher Pinzón 2022-06-01 16:26:27 -05:00 committed by GitHub
parent 34a98d2c20
commit b96eafb3c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -154,9 +154,10 @@ class FakeKey(BaseModel):
self.s3_backend = s3_backend
@property
def safe_name(self):
return urllib.parse.quote(self.name, safe="")
def safe_name(self, encoding_type=None):
if encoding_type == "url":
return urllib.parse.quote(self.name, safe="")
return self.name
@property
def version_id(self):

View File

@ -2064,7 +2064,7 @@ S3_BUCKET_GET_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
{% endif %}
{% for key in result_keys %}
<Contents>
<Key>{{ key.safe_name }}</Key>
<Key>{{ key.safe_name(encoding_type) }}</Key>
<LastModified>{{ key.last_modified_ISO8601 }}</LastModified>
<ETag>{{ key.etag }}</ETag>
<Size>{{ key.size }}</Size>
@ -2107,7 +2107,7 @@ S3_BUCKET_GET_RESPONSE_V2 = """<?xml version="1.0" encoding="UTF-8"?>
{% endif %}
{% for key in result_keys %}
<Contents>
<Key>{{ key.safe_name }}</Key>
<Key>{{ key.safe_name(encoding_type) }}</Key>
<LastModified>{{ key.last_modified_ISO8601 }}</LastModified>
<ETag>{{ key.etag }}</ETag>
<Size>{{ key.size }}</Size>