API | Operation | Description |
Tagging an object | Tags an uploaded object. | |
Querying object tags | Queries all tags of an object. | |
Deleting object tags | Deletes all tags of an object. |
PUT Object tagging
) is used to tag an object.public Guzzle\\Service\\Resource\\Model PutObjectTagging(array $args = array());
<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //Replace it with the actual `SecretId`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi$secretKey = "SECRETKEY"; //Replace it with the actual `SecretKey`, which can be viewed and managed in the CAM console 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->putObjectTagging(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'Key' => 'exampleobject','TagSet' => array(array('Key'=>'key1','Value'=>'value1',),array('Key'=>'key2','Value'=>'value2',),),));// Request succeededprint_r($result);} catch (\\Exception $e) {// Request failedecho "$e\\n";}
Parameter | Description | Type |
Bucket | Bucket of the object to tag in the format of BucketName-APPID . For more information, see Bucket Overview > Bucket Naming Conventions. | String |
Key | Key of the object to tag. Object key is the unique identifier of an object in a bucket. For more information, see Object Overview > Object Key. | String |
TagSet | Tags to add to the object | Array |
TagSet
member:Parameter | Description | Type |
Key | Tag key | String |
Value | Tag value | String |
GET Object tagging
) is used to query the existing tags of an object.public Guzzle\\Service\\Resource\\Model GetObjectTagging(array $args = array());
<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //Replace it with the actual `SecretId`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi$secretKey = "SECRETKEY"; //Replace it with the actual `SecretKey`, which can be viewed and managed in the CAM console 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->getObjectTagging(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'Key' => 'exampleobject',));// Request succeededprint_r($result);} catch (\\Exception $e) {// Request failedecho($e);}
Parameter | Description | Type |
Bucket | Bucket of the object to query in the format of BucketName-APPID . For more information, see Bucket Overview > Bucket Naming Conventions. | String |
Key | Key of the object to query. Object key is the unique identifier of an object in a bucket. For more information, see Object Overview > Object Key. | String |
GuzzleHttp\\Command\\Result Object([TagSet] => Array([0] => Array([Key] => key1[Value] => value1)[1] => Array([Key] => key2[Value] => value2))[RequestId] => NWRmMWVkMjFfMjJiMjU4NjRfNWQ3X2EwMWVj****)
Member Variable | Description | Type |
Key | Key of the tag | String |
Value | Value of the tag | String |
DELETE Object tagging
) is used to delete the existing tags of an object.public Guzzle\\Service\\Resource\\Model DeleteObjectTagging(array $args = array());
<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //Replace it with the actual `SecretId`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi$secretKey = "SECRETKEY"; //Replace it with the actual `SecretKey`, which can be viewed and managed in the CAM console 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->deleteObjectTagging(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'Key' => 'exampleobject',);// Request succeededprint_r($result);} catch (\\Exception $e) {// Request failedecho($e);}
Parameter | Description | Type |
Bucket | Bucket of the object to delete in the format of BucketName-APPID . For more information, see Bucket Overview > Bucket Naming Conventions. | String |
Key | Key of the object to delete Object key is the unique identifier of an object in a bucket. For more information, see Object Overview > Object Key. | String |
Was this page helpful?