Created
July 10, 2019 10:08
-
-
Save johnpaulhayes/b58a1bc8dd8c2de4fa4c1c8b17bd80af to your computer and use it in GitHub Desktop.
s3_lambda_zip_handler
This file contains 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
s3_resource = boto3.resource('s3') | |
zip_obj = s3_resource.Object(bucket_name="bucket_name_here", key=zip_key) | |
buffer = BytesIO(zip_obj.get()["Body"].read()) | |
z = zipfile.ZipFile(buffer) | |
for filename in z.namelist(): | |
file_info = z.getinfo(filename) | |
s3_resource.meta.client.upload_fileobj( | |
z.open(filename), | |
Bucket=bucket, | |
Key=f'{filename}' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment