API | Operation | Description |
Setting CORS configuration | Sets the CORS permissions of bucket | |
Querying CORS configuration | Queries the CORS configuration of a bucket | |
Deleting CORS configuration | Deletes the CORS configuration of a bucket |
public Guzzle\\Service\\Resource\\Model putBucketCors(array $args = array());
<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //Replace it with the actual SecretId, which can be viewed and managed at https://console.tencentcloud.com/cam/capi$secretKey = "SECRETKEY"; //Replace it with the actual SecretKey, which can be viewed and managed at https://console.tencentcloud.com/cam/capi$region = "ap-beijing"; //Replace it with the actual region, which can be viewed in the console at https://console.tencentcloud.com/cos5/bucket$cosClient = new Qcloud\\Cos\\Client(array('region' => $region,'schema' => 'https', // Protocol header, which is http by default'credentials'=> array('secretId' => $secretId ,'secretKey' => $secretKey)));try {$result = $cosClient->putBucketCors(array('Bucket' => 'examplebucket-1250000000', // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket'CORSRules' => array(array('AllowedHeaders' => array('*',),'AllowedMethods' => array('PUT', ),'AllowedOrigins' => array('*', ),'ExposeHeaders' => array('*', ),'MaxAgeSeconds' => 1,),// ... repeated)));// Request succeededprint_r($result);} catch (\\Exception $e) {// Request failedecho "$e\\n";}
Parameter Name | Type | Description | Required |
Bucket | Bucket for which CORS configuration is set, in the format of BucketName-APPID | String | Yes |
CORSRules | Array | CORS configuration list | Yes |
CORSRule | Array | CORS configuration | Yes |
AllowedMethods | String | Allowed HTTP operations. Enumerated values: GET, PUT, HEAD, POST, DELETE | Yes |
AllowedOrigins | String | Allowed source origins. The wildcard * is supported. Format: Protocol://domain name[:port] , e.g. http://www.qq.com | Yes |
AllowedHeaders | String | Custom HTTP request headers that can be included in subsequent OPTIONS requests sent. The wildcard * is supported. | No |
ExposeHeaders | String | Custom header information that can be received by the browser from the server | No |
MaxAgeSeconds | Int | Validity period of the OPTIONS request result | No |
ID | String | Rule ID | Yes |
public Guzzle\\Service\\Resource\\Model getBucketCors(array $args = array());
<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //Replace it with the actual SecretId, which can be viewed and managed at https://console.tencentcloud.com/cam/capi$secretKey = "SECRETKEY"; //Replace it with the actual SecretKey, which can be viewed and managed at https://console.tencentcloud.com/cam/capi$region = "ap-beijing"; //Replace it with the actual region, which can be viewed in the console at https://console.tencentcloud.com/cos5/bucket$cosClient = new Qcloud\\Cos\\Client(array('region' => $region,'schema' => 'https', // Protocol header, which is http by default'credentials'=> array('secretId' => $secretId ,'secretKey' => $secretKey)));try {$result = $cosClient->getBucketCors(array('Bucket' => 'examplebucket-1250000000' // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket));// Request succeededprint_r($result);} catch (\\Exception $e) {// Request failedecho($e);}
Parameter | Type | Description | Required |
Bucket | String | Bucket for which CORS configuration is queried, in the format of BucketName-APPID | Yes |
Guzzle\\Service\\Resource\\Model Object([data:protected] => Array([CORSRules] => Array([0] => Array([ID] => 1234[AllowedHeaders] => Array([0] => *)[AllowedMethods] => Array([0] => PUT)[AllowedOrigins] => Array([0] => http://www.qq.com)))[RequestId] => NWE3YzhkMmRfMTdiMjk0MGFfNTQzZl8xNWUw****))
Parameter Name | Type | Description | Parent Node |
CORSRules | Array | CORS configuration list | None |
CORSRule | Array | CORS configuration | CORSRules |
AllowedMethods | String | Allowed HTTP operations. Enumerated values: GET, PUT, HEAD, POST, DELETE | CORSRule |
AllowedOrigins | String | Allowed source origins. The wildcard * is supported. Format: Protocol://domain name[:port] , e.g. http://www.qq.com | CORSRule |
AllowedHeaders | String | Custom HTTP request headers that can be included in subsequent OPTIONS requests sent. The wildcard * is supported. | CORSRule |
ExposeHeaders | String | Custom header information that can be received by the browser from the server | CORSRule |
MaxAgeSeconds | Int | Validity period of the OPTIONS request result | CORSRule |
ID | String | Rule ID | CORSRule |
public Guzzle\\Service\\Resource\\Model deleteBucketCors(array $args = array());
<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //Replace it with the actual SecretId, which can be viewed and managed at https://console.tencentcloud.com/cam/capi$secretKey = "SECRETKEY"; //Replace it with the actual SecretKey, which can be viewed and managed at https://console.tencentcloud.com/cam/capi$region = "ap-beijing"; //Replace it with the actual region, which can be viewed in the console at https://console.tencentcloud.com/cos5/bucket$cosClient = new Qcloud\\Cos\\Client(array('region' => $region,'schema' => 'https', // Protocol header, which is http by default'credentials'=> array('secretId' => $secretId ,'secretKey' => $secretKey)));try {$result = $cosClient->deleteBucketCors(array('Bucket' => 'examplebucket-1250000000' // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket));// Request succeededprint_r($result);} catch (\\Exception $e) {// Request failedecho($e);}
Parameter | Type | Description | Required |
Bucket | String | Bucket for which CORS configuration is deleted, in the format of BucketName-APPID | Yes |
Was this page helpful?