亚马逊提供了一种简单的方法来查看我的S3存储桶或文件夹使用了多少存储空间吗?这样我就可以计算我的成本了,等等。
发布于 2016-12-21 07:16:14
两种方式,
使用aws cli
aws s3 ls --summarize --human-readable --recursive s3://bucket/folder/*
如果我们省略
最后,它将获得所有以您的文件夹名称开头的文件夹,并给出所有文件夹的总大小。
aws s3 ls --summarize --human-readable --recursive s3://bucket/folder
使用boto3接口
import boto3
def get_folder_size(bucket, prefix):
total_size = 0
for obj in boto3.resource('s3').Bucket(bucket).objects.filter(Prefix=prefix):
total_size += obj.size
return total_size
发布于 2017-09-01 14:30:40
亚马逊已经改变了Web界面,所以现在你可以在"More“菜单下看到"Get Size”。
发布于 2015-08-25 05:54:54
自2015年7月28日起,您可以通过CloudWatch获取此信息。
aws cloudwatch get-metric-statistics --namespace AWS/S3 --start-time 2015-07-15T10:00:00
--end-time 2015-07-31T01:00:00 --period 86400 --statistics Average --region us-east-1
--metric-name BucketSizeBytes --dimensions Name=BucketName,Value=myBucketNameGoesHere
Name=StorageType,Value=StandardStorage
Important: You must specify both StorageType and BucketName in the dimensions argument otherwise you will get no results.
https://stackoverflow.com/questions/32192391
复制相似问题