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. |
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);
Parameter | Description | Type |
setObjectTaggingRequest | Object tagging request | SetObjectTaggingRequest |
Request Member | Setting Method | Description | Type |
bucketName | Via a constructor or the set method | String | |
Key | Via a constructor or the set method | Key of the object to tag. An object key uniquely identifies an object in a bucket. For more information, see Object Overview > Object Key | String |
objectTagging | Via a constructor or the set method | Object tagging | ObjectTagging |
Parameter | Description | Type |
tagSet | Tags to add to the object | List<Tag> |
Parameter | Description | Type |
key | Tag key | String |
value | Tag 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());
Parameter | Description | Type |
getObjectTaggingRequest | Request to query the tags of an object | GetObjectTaggingRequest |
Request Member | Setting Method | Description | Type |
bucketName | Via a constructor or the set method | String | |
Key | Via a constructor or the set method | Key of the object to tag. An object key uniquely identifies an object in a bucket. For more information, see Object Overview > Object Key | String |
public DeleteObjectTaggingResult deleteObjectTagging(DeleteObjectTaggingRequest deleteObjectTaggingRequest);
String bucketName = "examplebucket-1250000000";String key = "exampleobject";DeleteObjectTaggingRequest deleteObjectTaggingRequest = new DeleteObjectTaggingRequest(bucketName, key);cosclient.deleteObjectTagging(deleteObjectTaggingRequest);
Parameter | Description | Type |
deleteObjectTaggingRequest | Request to delete the tags of an object | DeleteObjectTaggingRequest |
Request Member | Setting Method | Description | Type |
bucketName | Via a constructor or the set method | String | |
Key | Via a constructor or the set method | Key of the object to tag. An object key uniquely identifies an object in a bucket. For more information, see Object Overview > Object Key | String |
Was this page helpful?