更新时间:2025-12-04 GMT+08:00
获取对象标签
功能说明
获取指定桶中的对象标签。
方法定义
ObsClient->getObjectTagging(array $parameter)
请求参数
| 字段名 | 类型 | 约束 | 说明 |
|---|---|---|---|
| Bucket | string | 必选 | 桶名。 |
| Key | string | 必选 | 目标对象名。 |
| VersionId | string | 可选 | 待删除对象的版本号。 |
返回结果
| 字段名 | 类型 | 说明 | ||
|---|---|---|---|---|
| HttpStatusCode | integer | HTTP状态码。 | ||
| Reason | string | HTTP文本描述。 | ||
| RequestId | string | OBS服务端返回的请求ID。 | ||
| Tags | indexed array | 桶标签列表。 | ||
| - | Key | string | 标签的名字,最大36个字符。 | |
| Value | string | 标签的值,最大43个字符。 | ||
代码样例
try{
$resp = $obsClient -> getObjectTagging([
'Bucket' => 'bucketname',
'Key' => 'objectname',
]);
printf("RequestId:%s\n", $resp['RequestId']);
foreach ($resp['Tags'] as $index => $tag){
printf("TagSet[%d]\n", $index + 1);
printf("Key:%s\n", $tag['Key']);
printf("Value:%s\n", $tag['Value']);
}
}catch (Obs\Common\ObsException $obsException){
printf("ExceptionCode:%s\n", $obsException->getExceptionCode());
printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage());
} 父主题: 对象相关接口