通过 boto 的 AWS S3 - 检查磁盘 space

AWS S3 through boto - checking disk space

this question 类似,我想要一种方法来检查 space S3 存储桶正在使用多少磁盘。但是,我想通过 python 中的 boto 库来完成,而不是通过命令行脚本。

我查看了 the documentation page 并没有看到任何可以完成工作的东西。有没有办法做到这一点,还是我被困住了?

由于 S3 只是一个 key/value 商店,您需要手动计算。它没有您可以查询的文件系统的概念。所以你会想做这样的事情:

import boto
s3 = boto.connect_s3()
bucket = s3.lookup('mybucketname')
total_bytes = 0
for key in bucket:
       total_bytes += key.size
print total_bytes