response-content-disposition=inline
parameter to the end of the obtained URL.response-content-disposition=attachment
parameter to the end of the obtained URL.// Obtain a signed download URL of an object.<?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 {$bucket = "examplebucket-1250000000"; // Bucket in the format of BucketName-APPID$key = "exampleobject"; // Object key, the unique identifier of the object in the bucket$signedUrl = $cosClient->getObjectUrl($bucket, $key, '+10 minutes');// Request succeededecho $signedUrl;} catch (\\Exception $e) {// Request failedprint_r($e);}
// Obtain an unsigned download URL of an object for anonymous downloads or delivery.<?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 {$bucket = 'examplebucket-125000000'; // Bucket in the format of BucketName-APPID$key = "exampleobject"; // Object key, the unique identifier of the object in the bucket$Url = $cosClient -> getObjectUrlWithoutSign($bucket, $key);// Request succeededecho $Url;} catch (\\Exception $e) {// Request failedprint_r($e);}
Parameter | Description | Type | Required |
Bucket | Bucket name in the format of BucketName-APPID . | String | Yes |
Key | Object key (object name), the unique identifier of an object in a bucket. For more information, please see Object Overview. | String | Yes |
Expires | Validity duration of a signature. Default: 1,800 seconds | String | Yes |
Was this page helpful?