API | 操作名 | 操作描述 |
设置对象标签 | 为对象设置标签 | |
查询对象标签 | 查询指定对象下已有的对象标签 | |
删除对象标签 | 删除指定对象下已有的对象标签 |
public SetObjectTaggingResult setObjectTagging(SetObjectTaggingRequest setObjectTaggingRequest);
String bucketName = "examplebucket-1250000000";String key = "exampletkey";List<Tag> tags = new LinkedList<>();tags.add(new Tag("tag1", "value1"));tags.add(new Tag("tag2", "value2"));ObjectTagging objectTagging = new ObjectTagging(tags);SetObjectTaggingRequest setObjectTaggingRequest = new SetObjectTaggingRequest(bucketName, key, objectTagging);cosclient.setObjectTagging(setObjectTaggingRequest);
String bucketName = "examplebucket-1250000000";String key = "testfiles/testTagging.txt";InputStream is = new ByteArrayInputStream(new byte[]{'d', 'a', 't', 'a'});ObjectMetadata objectMetadata = new ObjectMetadata();objectMetadata.setHeader("x-cos-tagging", "tag1=value1&tag2=value2");cosclient.putObject(bucketName, key, is, objectMetadata);
参数名称 | 描述 | 类型 |
setObjectTaggingRequest | 对象标签设置请求 | SetObjectTaggingRequest |
参数名称 | 描述 | 类型 |
tagSet | 对象的标签配置集合 | List<Tag> |
参数名称 | 描述 | 类型 |
key | 标签的 key | String |
value | 标签的 value | String |
public GetObjectTaggingResult getObjectTagging(GetObjectTaggingRequest getObjectTaggingRequest);
String bucketName = "exampletbucket-1250000000";String key = "exampletkey";GetObjectTaggingRequest getObjectTaggingRequest = new GetObjectTaggingRequest(bucketName, key);GetObjectTaggingResult getObjectTaggingResult = cosclient.getObjectTagging(getObjectTaggingRequest);List<Tag> resultTagSet = getObjectTaggingResult.getTagSet();System.out.println(resultTagSet.toString());
参数名称 | 描述 | 类型 |
getObjectTaggingRequest | 对象标签查询请求 | GetObjectTaggingRequest |
public DeleteObjectTaggingResult deleteObjectTagging(DeleteObjectTaggingRequest deleteObjectTaggingRequest);
String bucketName = "examplebucket-1250000000";String key = "exampleobject";DeleteObjectTaggingRequest deleteObjectTaggingRequest = new DeleteObjectTaggingRequest(bucketName, key);cosclient.deleteObjectTagging(deleteObjectTaggingRequest);
参数名称 | 描述 | 类型 |
deleteObjectTaggingRequest | 对象标签删除请求 | DeleteObjectTaggingRequest |
本页内容是否解决了您的问题?