Skip to content

Commit

Permalink
The current version only checks for system-defined "Content-Encoding"…
Browse files Browse the repository at this point in the history
… metadata set to "gzip" on an S3 object. Some tools do not properly set this metadata on write and AWS APIs to add metadata to an S3 object can only add it as user-defined metadata. The equivalent Amazon S3 user-defined metadata attribute is "x-amz-meta-content-encoding". This update adds an additional test for whether the user-defined metadata attribute "x-amz-meta-content-encoding" is set to "gzip". (#16)
  • Loading branch information
jleto authored Jul 22, 2021
1 parent dd24621 commit b817be9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aws_s3--0.0.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ AS $$
response = obj.get()
content_encoding = response.get('ContentEncoding')
body = response['Body']
user_content_encoding = response.get('x-amz-meta-content-encoding')

with tempfile.NamedTemporaryFile() as fd:
if content_encoding and content_encoding.lower() == 'gzip':
if (content_encoding and content_encoding.lower() == 'gzip') or (user_content_encoding and user_content_encoding.lower() == 'gzip'):
with gzip.GzipFile(fileobj=body) as gzipfile:
while fd.write(gzipfile.read(204800)):
pass
Expand Down

0 comments on commit b817be9

Please sign in to comment.