Creating a Bucket
API Description
You can use this API to create a bucket and name it as you specify. The created bucket name must be unique in OBS. If a user repeatedly creates buckets with the same name in one region, status code 200 is returned. In other cases, status code 409 is returned. Each user can create a maximum of 100 buckets.
Method Definition
func (obsClient ObsClient) CreateBucket(input *CreateBucketInput) (output *BaseModel, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) CreateBucketWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error)
Request Parameter
| Field | Type | Optional or Mandatory |
|---|---|---|
| input | Mandatory |
Returned Results
| Field | Type |
|---|---|
| output | |
| err | error |
Sample Code
func main() { input := &obs.CreateBucketInput{} input.Bucket = "bucketname" input.ACL = obs.AclPrivate input.StorageClass = obs.StorageClassWarm output, err := obsClient.CreateBucket(input) if err == nil { fmt.Printf("RequestId:%s\n", output.RequestId) } else { if obsError, ok := err.(obs.ObsError); ok { fmt.Println(obsError.Code) fmt.Println(obsError.Message) } else { fmt.Println(err) } } }
Last Article: Bucket-Related APIs
Next Article: Listing Buckets
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.