Skip to content

Instantly share code, notes, and snippets.

@johnpaulhayes
Created July 10, 2019 10:08
Show Gist options
  • Save johnpaulhayes/b58a1bc8dd8c2de4fa4c1c8b17bd80af to your computer and use it in GitHub Desktop.
Save johnpaulhayes/b58a1bc8dd8c2de4fa4c1c8b17bd80af to your computer and use it in GitHub Desktop.
s3_lambda_zip_handler
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