I would like to get the size (in bytes and # of keys) of an Amazon S3 bucket.
I am looking for an effective way to get the size of a bucket.
One possible way (which is NOT effective): I can get a list of keys from the basket and summarize the size of each key. This is inefficient when I have a thousand keys, because I have to look for every key size.
Is there an effective solution?
UPDATE:
The following code is not what I'm looking for (because it is inefficient):
bucket = conn.get_bucket("bucket_name") total_size = 0 for key in bucket.list(): total_size += key.size
Celik source share