-
-
Save flyher/1a0b85ed0226a6ce7276af4abe67ece3 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
@nberserk
Thank you very much!
And we can get one file size with this code: