From b817be9caf54e5b09c5c6edb924cf1b17df0e75c Mon Sep 17 00:00:00 2001 From: Justin Leto Date: Thu, 22 Jul 2021 00:30:43 -0400 Subject: [PATCH] The current version only checks for system-defined "Content-Encoding" 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) --- aws_s3--0.0.1.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aws_s3--0.0.1.sql b/aws_s3--0.0.1.sql index 318cb2e..93ee6d0 100644 --- a/aws_s3--0.0.1.sql +++ b/aws_s3--0.0.1.sql @@ -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