Feature Overview
This document provides an overview of APIs and SDK code samples for creating a bucket.
Note
We recommend users to use temporary keys when calling the SDK to enhance security through temporary authorization. When applying for temporary keys, please follow the principle of least privilege to prevent leakage of resources beyond the target bucket or object.
If you must use a permanent key, we recommend you follow the Notes on Principle of Least Privilege to limit the scope of permission on the permanent key.
API | Operation | Description |
Create a bucket. | Creates a bucket under a specified account |
Create a bucket.
Note
This API is used to create a bucket under the specified account. You can create multiple buckets under the same user account. The maximum number is 200 (regardless of region). There is no limit to the number of objects in the bucket. Bucket creation is a low-frequency operation. We recommended you create a bucket in the console and perform object operations in the SDK.
Method prototype
public Guzzle\Service\Resource\Model createBucket(array $args = array());
Sample Request
<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //Replace it with the actualSecretId, which can be viewed and managed in the CAM console at https://console.cloud.tencent.com/cam/capi$secretKey = "SECRETKEY"; //Replace it with the actualSecretKey, which can be viewed and managed in the CAM console at https://console.cloud.tencent.com/cam/capi$region = "ap-beijing"; //Replace it with the actualregion, which can be viewed in the console at https://console.cloud.tencent.com/cos5/bucket$cosClient = new Qcloud\Cos\Client(array('region' => $region,'schema' => 'https', //Protocol header, default is http'credentials'=> array('secretId' => $secretId ,'secretKey' => $secretKey)));try {$result = $cosClient->createBucket(array('Bucket' => 'examplebucket-125000000' // Bucket name, composed of BucketName-Appid, can be viewed in the COS console at https://console.cloud.tencent.com/cos5/bucket));// Request successfulprint_r($result);} catch (\Exception $e) {// Request failedecho($e);}
Description
Parameter name | Parent Node | Description | Local Disk Types |
Bucket | - | Bucket name in the format of BucketName-APPID | String |