Feature Overview
This document provides an overview of APIs and SDK code samples for object tagging.
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 |
Tagging an Object
Note
This API (
PUT Object tagging) is used to tag an object.Method prototype
public Guzzle\Service\Resource\Model PutObjectTagging(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->putObjectTagging(array('Bucket' => 'examplebucket-1250000000', // Bucket name, composed of BucketName-Appid, can be viewed in the COS console at https://console.cloud.tencent.com/cos5/bucket'Key' => 'exampleobject','TagSet' => array(array('Key'=>'key1','Value'=>'value1',),array('Key'=>'key2','Value'=>'value2',),),));// Request successfulprint_r($result);} catch (\Exception $e) {// Request failedecho "$e\n";}
Description
Parameter name | Description | Local Disk Types |
Bucket | Set the bucket containing the object to be tagged, in the format BucketName-APPID. For more information, please refer to 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 |
Description of the
TagSet member:Parameter name | Description | Local Disk Types |
Key | Tag key | String |
Value | Tag value | String |
Querying object tags
Note
This API (
GET Object tagging) is used to query the existing tags of an object.Method prototype
public Guzzle\Service\Resource\Model GetObjectTagging(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->getObjectTagging(array('Bucket' => 'examplebucket-1250000000', // Bucket name, composed of BucketName-Appid, can be viewed in the COS console at https://console.cloud.tencent.com/cos5/bucket'Key' => 'exampleobject',));// Request successfulprint_r($result);} catch (\Exception $e) {// Request failedecho($e);}
Description
Parameter name | Description | Local Disk Types |
Bucket | Query the bucket where the tagged object is located, in the format BucketName-APPID. For more information, please refer to 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 |
Sample response
GuzzleHttp\Command\Result Object([TagSet] => Array([0] => Array([Key] => key1[Value] => value1)[1] => Array([Key] => key2[Value] => value2))[RequestId] => NWRmMWVkMjFfMjJiMjU4NjRfNWQ3X2EwMWVj****)
Response description
Member Variables | Description | Local Disk Types |
Key | Tag key | String |
Value | Tag value | String |
Deleting object tags
Note
This API (
DELETE Object tagging) is used to delete the existing tags of an object.Method prototype
public Guzzle\Service\Resource\Model DeleteObjectTagging(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->deleteObjectTagging(array('Bucket' => 'examplebucket-1250000000', // Bucket name, composed of BucketName-Appid, can be viewed in the COS console at https://console.cloud.tencent.com/cos5/bucket'Key' => 'exampleobject',);// Request successfulprint_r($result);} catch (\Exception $e) {// Request failedecho($e);}
Description
Parameter name | Description | Local Disk Types |
Bucket | Delete the bucket containing the tagged object, formatted as BucketName-APPID. For more information, please refer to Naming Conventions. | String |
Key | Delete the object key with tags. The object key (Key) is the unique identifier of the object in the bucket. For more information, please refer to Object Key. | String |