Skip to content

how to unzip a tar.gz file downloaded from s3 in aws lambda?

0

I'm using Python Boto 3 and aws cli to download and possibly unzip a file.tar.gz. with cli. how to unzip the file in lambda and i want to add a file to this and re-zip it and upload it to a s3 bucket, provided the file is no more than a gig or so . i'm aware of the lambda execution time limit and memory. any samples or examples would be great.

1 Answer
1

The tarfile module can be used to unpack in Python.
https://docs.python.org/3/library/tarfile.html

sample

import tarfile

file = tarfile.open('filename.tar.gz', 'r = gz')
file.extractall()
file.close()

If my answer is helpful, please approve it for the betterment of the community.

EXPERT

answered 3 years ago

  • @Riku_Kobayashi - thanks , i have file stored in an s3 location. i need to download it first, right?

  • Yes, you need to download the S3 file to Lambda and then unzip it.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.