in source/s3_helper.py [0:0]
def translate_response_headers_to_writegetobjectresponse(headers):
"""
Convert response headers received from s3 presigned download call to the format similar to arguments of WriteGetObjectResponse API.
:param headers: http headers received as part of response from downloading the object from s3
"""
S3GET_TO_WGOR_HEADER_TRANSLATION_MAP = {
"accept-ranges": ("AcceptRanges", str),
"Cache-Control": ("CacheControl", str),
"Content-Disposition": ("ContentDisposition", str),
"Content-Encoding": ("ContentEncoding", str),
"Content-Language": ("ContentLanguage", str),
"Content-Length": ("ContentLength", int),
"Content-Range": ("ContentRange", str),
"Content-Type": ("ContentType", str),
"x-amz-delete-marker": ("DeleteMarker", bool),
"ETag": ("ETag", str),
"Expires": ("Expires", str),
"x-amz-expiration": ("Expiration", str),
"Last-Modified": ("LastModified", str),
"x-amz-missing-meta": ("MissingMeta", str),
"x-amz-meta-": ("Metadata", str),
"x-amz-object-lock-mode": ("ObjectLockMode", str),
"x-amz-object-lock-legal-hold": ("ObjectLockLegalHoldStatus", str),
"x-amz-object-lock-retain-until-date": ("ObjectLockRetainUntilDate", str),
"x-amz-mp-parts-count": ("PartsCount", int),
"x-amz-replication-status": ("ReplicationStatus", str),
"x-amz-request-charged": ("RequestCharged", str),
"x-amz-restore": ("Restore", str),
"x-amz-server-side-encryption": ("ServerSideEncryption", str),
"x-amz-server-side-encryption-customer-algorithm": ("SSECustomerAlgorithm", str),
"x-amz-server-side-encryption-aws-kms-key-id": ("SSEKMSKeyId", str),
"x-amz-server-side-encryption-customer-key-MD5": ("SSECustomerKeyMD5", str),
"x-amz-storage-class": ("StorageClass", str),
"x-amz-tagging-count": ("TagCount", int),
"x-amz-version-id": ("VersionId", str),
}
transformed_headers = {}
for header_name in headers:
if header_name in S3GET_TO_WGOR_HEADER_TRANSLATION_MAP:
header_value = S3GET_TO_WGOR_HEADER_TRANSLATION_MAP[header_name][1](headers[header_name])
transformed_headers[S3GET_TO_WGOR_HEADER_TRANSLATION_MAP[header_name][0]] = header_value
return transformed_headers