API | 操作名 | 操作描述 |
设置存储桶标签 | 为已存在的存储桶设置标签 | |
查询存储桶标签 | 查询指定存储桶下已有的存储桶标签 | |
删除存储桶标签 | 删除指定的存储桶标签 |
// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";PutBucketTaggingRequest putBucketTaggingRequest =new PutBucketTaggingRequest(bucket);// 设置标签putBucketTaggingRequest.addTag("key", "value");putBucketTaggingRequest.addTag("hello", "world");cosXmlService.putBucketTaggingAsync(putBucketTaggingRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {PutBucketTaggingResult putBucketTaggingResult =(PutBucketTaggingResult) result;}// 如果您使用 kotlin 语言来调用,请注意回调方法中的异常是可空的,否则不会回调 onFail 方法,即:// clientException 的类型为 CosXmlClientException?,serviceException 的类型为 CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";GetBucketTaggingRequest getBucketTaggingRequest =new GetBucketTaggingRequest(bucket);cosXmlService.getBucketTaggingAsync(getBucketTaggingRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {GetBucketTaggingResult getBucketTaggingResult =(GetBucketTaggingResult) result;}// 如果您使用 kotlin 语言来调用,请注意回调方法中的异常是可空的,否则不会回调 onFail 方法,即:// clientException 的类型为 CosXmlClientException?,serviceException 的类型为 CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";DeleteBucketTaggingRequest deleteBucketTaggingRequest =new DeleteBucketTaggingRequest(bucket);cosXmlService.deleteBucketTaggingAsync(deleteBucketTaggingRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {DeleteBucketTaggingResult getBucketTaggingResult =(DeleteBucketTaggingResult) result;}// 如果您使用 kotlin 语言来调用,请注意回调方法中的异常是可空的,否则不会回调 onFail 方法,即:// clientException 的类型为 CosXmlClientException?,serviceException 的类型为 CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
本页内容是否解决了您的问题?