This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import zlib | |
def decompress_object(bucket, key, out_file): | |
s3 = boto3.client("s3") | |
body = s3.get_object(Bucket=bucket, Key=key)['Body'] | |
with open(out_file, "ab") as out: | |
decompressor = zlib.decompressobj(zlib.MAX_WBITS|32) | |
for chunk in body.iter_chunks(): | |
out.write(decompressor.decompress(chunk)) |