PUT 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. Buckets with the same name can only be created by the same user in the same region. In other cases, creating a bucket with a used name will fail. Each user can create a maximum of 100 buckets.
Method Definition
1. ObsClient->createBucket(array $parameter) 2. ObsClient->createBucketAsync(array $parameter, callable $callback)
Request Parameter
Field |
Type |
Optional or Mandatory |
Description |
---|---|---|---|
Bucket |
string |
Mandatory |
Bucket name
A bucket name must comply with the following rules:
|
ACL |
string |
Optional |
Pre-defined access control policy that can be specified during the bucket creation |
StorageClass |
string |
Optional |
Bucket storage class that can be specified during the bucket creation |
LocationConstraint |
string |
Mandatory unless the region where the OBS service resides is not the default region. |
Region where a bucket will be created. This parameter is not required if the endpoint belongs to the default CN North-Beijing1 (cn-north-1) region, but this parameter is a must if the endpoint belongs to any other regions. For the valid regions, see Click Regions and Endpoints. For more information about OBS regions and endpoints, see Regions and Endpoints. |
Returned Result
Field |
Type |
Description |
---|---|---|
HttpStatusCode |
integer |
HTTP status code |
Reason |
string |
Reason description |
RequestId |
string |
Request ID returned by the OBS server |
Sample Code
try{ $resp = $obsClient -> createBucket([ 'Bucket' => 'bucketname', 'ACL' => 'private', 'StorageClass' => ObsClient::StorageClassStandard ]); printf("RequestId:%s\n", $resp['RequestId']); }catch (Obs\Common\ObsException $obsException){ printf("ExceptionCode:%s\n", $obsException->getExceptionCode()); printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage()); }
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