Listing Buckets
API Description
You can use this API to obtain the bucket list. In the list, bucket names are displayed in lexicographical order.
Method Definition
func (obsClient ObsClient) ListBuckets(input *ListBucketsInput) (output *ListBucketsOutput, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) ListBucketsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *ListBucketsOutput, err error)
Request Parameter
| Field | Type | Optional or Mandatory |
|---|---|---|
| input | Optional |
Returned Result
| Field | Type |
|---|---|
| output | |
| err | error |
Sample Code
func main() { output, err := obsClient.ListBuckets(nil) if err == nil { fmt.Printf("RequestId:%s\n", output.RequestId) fmt.Printf("Owner.ID:%s\n", output.Owner.ID) for index, val := range output.Buckets { fmt.Printf("Bucket[%d]-Name:%s,CreationDate:%s\n", index, val.Name, val.CreationDate) } } else { if obsError, ok := err.(obs.ObsError); ok { fmt.Println(obsError.Code) fmt.Println(obsError.Message) } else { fmt.Println(err) } } }
Last Article: Creating a Bucket
Next Article: Checking Whether a Bucket Exists
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.