Project currently maintains S3 bucket which holds a large zip size 1.5 GB containing .xpt and .sas7dbat files. Unzipped file size is 20 GB.
Trying to unzip file and push the same folder structure to S3
Following code works for a small zip files but fails for large Zip file (1.5GB) :
for obj in bucket.objects.all():
#file_name = os.path.abspath(obj.key) # get full path of files
key = urlparse(obj.key.encode('utf8'))
obj = client.get_object(Bucket='my-zip-bucket', Key=obj.key)
with io.BytesIO(obj["Body"].read()) as tf:
# rewind the file
tf.seek(0)
with zipfile.ZipFile(tf, mode='r') as zipf:
for file in zipf.infolist():
fileName = file.filename
putFile = client.put_object(Bucket='my-un-zip-bucket-', Key=fileName, Body=zipf.read(file))
putObjects.append(putFile)
Error : Memory Size: 3008 MB Max Memory Used: 3008 MB
I would like to validate :
- AWS-Lambda is not a suitable solution for large files ?
- Should I use different libraries / approach rather than reading everything in memory