how to get s3 bucket size via aws-sdk (javascript or node)

佐手、 提交于 2021-02-08 03:38:10

问题


I tried to find/get s3 bucket information using javascript/nodejs aws-sdk, but I didnt find such apis. How to get s3 bucket size / information via aws-sdk (javascript or node) api.


回答1:


There is no API to get the bucket size other than enumerating all the objects.

One alternative approach would be to investigate the billing, but I think that will only yield inaccurate data as the billing handles a specific size over a specific time.




回答2:


Once a day the size of the bucket is reported to CloudWatch. The Metric is called BucketSizeBytes and you can supply the BucketName as a dimension and the StorageType (AllStorageTypes, StandardStorage, StandardIAStorage, ReducedRedundancyStorage).

You can use the JavaScript SDK to acceess the data in CloudWatch via the getMetricStatistics of the CloudWatch client. http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#getMetricStatistics-property



来源:https://stackoverflow.com/questions/40042150/how-to-get-s3-bucket-size-via-aws-sdk-javascript-or-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!