Last active
January 31, 2024 11:02
-
-
Save nberserk/7723597ca73526e1c25c to your computer and use it in GitHub Desktop.
calculating S3 file size containing <your_filter> in <your_bucket> using boto3 python library.
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
import boto3 | |
s3 = boto3.resource('s3') | |
bucket = s3.Bucket('<your_bucket>') | |
size = 0 | |
for o in bucket.objects.all(): | |
if '<your_filter>' in o.key: | |
print o, o.size | |
size += o.size | |
print 's3 size = %.3f GB' % (size/1024/1024/1024) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment