如何通过aws-sdk(javascript或节点)获取s3桶大小

时间:2022-04-30 10:44:48

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.

我试图使用javascript / nodejs aws-sdk查找/获取s3存储桶信息,但我没有找到这样的api。如何通过aws-sdk(javascript或node)api获取s3桶大小/信息。

2 个解决方案

#1


2  

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

除了枚举所有对象之外,没有API可以获取存储桶大小。

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


0  

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).

每天一次将桶的大小报告给CloudWatch。度量标准称为BucketSizeBytes,您可以将BucketName作为维度和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

您可以使用JavaScript SDK通过CloudWatch客户端的getMetricStatistics加入CloudWatch中的数据。 http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#getMetricStatistics-property

#1


2  

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

除了枚举所有对象之外,没有API可以获取存储桶大小。

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


0  

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).

每天一次将桶的大小报告给CloudWatch。度量标准称为BucketSizeBytes,您可以将BucketName作为维度和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

您可以使用JavaScript SDK通过CloudWatch客户端的getMetricStatistics加入CloudWatch中的数据。 http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#getMetricStatistics-property