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. |
Bucket location This parameter is not required if the endpoint belongs to the default North China 1 region (cn-north-1). This parameter is a must if the endpoint belongs to any other regions. Click here to query currently valid regions. For details 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());
}
Last Article: Bucket-Related APIs
Next Article: GET Buckets
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.