Created
September 1, 2011 13:15
-
-
Save garnaat/1186142 to your computer and use it in GitHub Desktop.
Get total bytes in a bucket
This file contains hidden or 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
# Iterates over all the keys in a bucket and totals the bytes used | |
# NOTE: if you have a lot of keys, this could take a LONG time. | |
import boto | |
def bucket_du(bucket_name): | |
s3 = boto.connect_s3() | |
bucket = s3.lookup(bucket_name) | |
total_bytes = 0 | |
for key in bucket: | |
total_bytes += key.size | |
return total_bytes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment