cos:GetService when you configure the authorization policy. For more authorization information, see CAM-supported business APIs.cos:PutBucket when you configure the authorization policy. For more authorization information, see CAM-supported business APIs.cos:HeadBucket when you configure the authorization policy. For more authorization information, see CAM-supported business APIs.cos:DeleteBucket when you configure the authorization policy. For more authorization information, see CAM-supported business APIs.Feature Name | Description | Example code |
Querying the Bucket List | Querying the list of all buckets under a specified account. | |
Creating a Bucket | Create a bucket under a specified account. | |
Head Bucket | Check whether a bucket exists. | |
Deleting a Bucket | Delete empty buckets under a specified account. |
GetServiceRequest getServiceRequest = new GetServiceRequest();cosXmlService.getServiceAsync(getServiceRequest, new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {GetServiceResult getServiceResult = (GetServiceResult) result;}// If you call the API using kotlin, note that the exception in the callback method must be nullable. Otherwise, the onFail method will not be called, as follows:// The type of clientException is CosXmlClientException?, and the type of serviceException is CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
// A bucket name consists of bucketname-appid. You must include the appid. You can view bucket names in the COS console. https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";PutBucketRequest putBucketRequest = new PutBucketRequest(bucket);// Whether the specified bucket is configured with Multi-AZputBucketRequest.enableMAZ(false);cosXmlService.putBucketAsync(putBucketRequest, new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {PutBucketResult putBucketResult = (PutBucketResult) result;}// If you call the API using kotlin, note that the exception in the callback method must be nullable. Otherwise, the onFail method will not be called, as follows:// The type of clientException is CosXmlClientException?, and the type of serviceException is CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
// A bucket name consists of bucketname-appid. You must include the appid. You can view bucket names in the COS console. https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";HeadBucketRequest headBucketRequest = new HeadBucketRequest(bucket);cosXmlService.headBucketAsync(headBucketRequest, new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {HeadBucketResult headBucketResult = (HeadBucketResult) result;}// If you call the API using kotlin, note that the exception in the callback method must be nullable. Otherwise, the onFail method will not be called, as follows:// The type of clientException is CosXmlClientException?, and the type of serviceException is CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
// A bucket name consists of bucketname-appid. You must include the appid. You can view bucket names in the COS console. https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";DeleteBucketRequest deleteBucketRequest = new DeleteBucketRequest(bucket);cosXmlService.deleteBucketAsync(deleteBucketRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {DeleteBucketResult deleteBucketResult = (DeleteBucketResult) result;}@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários