Overview
This document provides an overview of APIs and SDK code samples for object tagging.
Tagging an Object
Feature description
This API (PUT Object tagging
) is used to tag an object.
Method prototype
public Guzzle\Service\Resource\Model PutObjectTagging(array $args = array());
Sample request
<?php
require dirname(__FILE__) . '/../vendor/autoload.php';
$secretId = "SECRETID";
$secretKey = "SECRETKEY";
$region = "ap-beijing";
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'schema' => 'https',
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));
try {
$result = $cosClient->putObjectTagging(array(
'Bucket' => 'examplebucket-1250000000',
'Key' => 'exampleobject',
'TagSet' => array(
array('Key'=>'key1',
'Value'=>'value1',
),
array('Key'=>'key2',
'Value'=>'value2',
),
),
));
print_r($result);
} catch (\Exception $e) {
echo "$e\n";
}
Parameter description
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 |
Description of the TagSet
member:
Parameter |
Description |
Type |
Key |
Tag key |
String |
Value |
Tag value |
String |
Feature description
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
<?php
require dirname(__FILE__) . '/../vendor/autoload.php';
$secretId = "SECRETID";
$secretKey = "SECRETKEY";
$region = "ap-beijing";
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'schema' => 'https',
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));
try {
$result = $cosClient->getObjectTagging(array(
'Bucket' => 'examplebucket-1250000000',
'Key' => 'exampleobject',
));
print_r($result);
} catch (\Exception $e) {
echo($e);
}
Parameter description
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 Variable |
Description |
Type |
Key |
Key of the tag |
String |
Value |
Value of the tag |
String |
Feature description
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
<?php
require dirname(__FILE__) . '/../vendor/autoload.php';
$secretId = "SECRETID";
$secretKey = "SECRETKEY";
$region = "ap-beijing";
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'schema' => 'https',
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));
try {
$result = $cosClient->deleteObjectTagging(array(
'Bucket' => 'examplebucket-1250000000',
'Key' => 'exampleobject',
);
print_r($result);
} catch (\Exception $e) {
echo($e);
}
Parameter description
Apakah halaman ini membantu?