API | Operation | Description |
Setting bucket referer configuration | Sets a bucket referer allowlist or blocklist | |
Querying bucket referer configuration | Queries a bucket referer allowlist or blocklist |
public Guzzle\\Service\\Resource\\Model putBucketReferer(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->putBucketReplication(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'Status' => 'Enabled', // Whether to enable hotlink protection. Enumerated values: “Enabled”, “Disabled”'RefererType' => 'White-List', // Hotlink protection type. Enumerated values: “Black-List”, “White-List”'DomainList' => array('Domains' => array('*.qq.com', // A single domain'*.qcloud.com', // A single domain)), // Domain list'EmptyReferConfiguration' => 'Allow', // Whether to allow access with an empty referer. Enumerated values: “Allow”, “Deny” (default)),);// Request succeededprint_r($result);} catch (\\Exception $e) {// Request failedecho($e);}
Parameter | Description | Type | Required |
Bucket | Bucket name in the format of BucketName-APPID . | String | Yes |
Status | Whether to enable hotlink protection. Enumerated values: Enabled , Disabled | String | Yes |
RefererType | Hotlink protection type. Enumerated values: Black-List , White-List | String | Yes |
DomainList | Domain list | Array | Yes |
EmptyReferConfiguration | Whether to allow access with an empty referer. Enumerated values: Allow , Deny (default) | String | No |
public Guzzle\\Service\\Resource\\Model getBucketReferer(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->getBucketReferer(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 | Description | Type | Required |
Bucket | Bucket name in the format of BucketName-APPID . | String | Yes |
GuzzleHttp\\Command\\Result Object([RequestId] => NjE0NTk2ZWVfZmQzNDJjMGJfMWNiNmVfN2Y1MWQx[ContentType] => application/xml[ContentLength] => 260[Status] => Enabled[RefererType] => White-List[EmptyReferConfiguration] => Allow[DomainList] => Array([Domain] => Array([0] => *.qq.com[1] => *.qcloud.com))[Bucket] => examplebucket-1250000000[Location] => examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/)
Was this page helpful?