HEAD Bucket
API Description
You can use this API to check whether a bucket exists. If the returned HTTP status code is 200, the bucket exists. If the returned HTTP status code is 404, the bucket does not exist.
Method Definition
func (obsClient ObsClient) HeadBucket(bucketName string) (output *BaseModel, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) HeadBucketWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *BaseModel, 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() { _, err := obsClient.HeadBucket("bucketname") if err == nil { fmt.Println("Bucket exists") } else { if obsError, ok := err.(obs.ObsError); ok { if obsError.StatusCode == 404 { fmt.Println("Bucket does not exists") } else { fmt.Printf("StatusCode:%d\n", obsError.StatusCode) } } else { fmt.Println(err) } } }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot