Obtaining Bucket Storage Information
API Description
You can use this API to obtain storage information about a bucket, including the bucket size and number of objects in the bucket.
Method Definition
func (obsClient ObsClient) GetBucketStorageInfo(bucketName string) (output *GetBucketStorageInfoOutput, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) GetBucketStorageInfoWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketStorageInfoOutput, err error)
Request Parameter
| Field | Type | Optional or Mandatory | Description |
|---|---|---|---|
| bucketName | string | Mandatory | Bucket name |
Returned Result
| Field | Type |
|---|---|
| output | |
| err | error |
Sample Code
func main() { output, err := obsClient.GetBucketStorageInfo("bucketname") if err == nil { fmt.Printf("RequestId:%s\n", output.RequestId) fmt.Printf("Size:%d, ObjectNumber:%d\n", output.Size, output.ObjectNumber) } else { if obsError, ok := err.(obs.ObsError); ok { fmt.Println(obsError.Code) fmt.Println(obsError.Message) } else { fmt.Println(err) } } }
Last Article: Obtaining a Bucket Location
Next Article: Setting a Bucket Quota
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.