API | Operation | Description |
Setting a custom domain | Sets a custom domain for a bucket | |
Querying a custom endpoint | Queries the custom endpoint of a bucket | |
Deleting a custom domain | Deletes the custom domain configuration of a bucket |
// Bucket name in the format of `BucketName-APPID` (`APPID` is required), which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.String bucket = "examplebucket-1250000000";PutBucketDomainRequest putBucketDomainRequest =new PutBucketDomainRequest(bucket);DomainConfiguration.DomainRule domainRule = new DomainConfiguration.DomainRule(DomainConfiguration.STATUS_ENABLED,"www.example.com",DomainConfiguration.TYPE_REST);domainRule.forcedReplacement = DomainConfiguration.REPLACE_CNAME;putBucketDomainRequest.addDomainRule(domainRule);cosXmlService.putBucketDomainAsync(putBucketDomainRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {PutBucketDomainResult putBucketDomainResult =(PutBucketDomainResult) result;}// If you use the Kotlin language to call this, please note that the exception in the callback method is nullable; otherwise, the onFail method will not be called back, that is:// clientException is of type CosXmlClientException? and serviceException is of type CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
Status Code | Description |
HTTP 409 Conflict | The domain record already exists, and forced overwrite is not specified in the request; OR the domain record does not exist, and forced overwrite is specified in the request |
HTTP 451 Unavailable For Legal Reasons | The domain does not have an ICP filing in the Chinese mainland |
// Bucket name in the format of `BucketName-APPID` (`APPID` is required), which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.String bucket = "examplebucket-1250000000";GetBucketDomainRequest getBucketDomainRequest =new GetBucketDomainRequest(bucket);cosXmlService.getBucketDomainAsync(getBucketDomainRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {GetBucketDomainResult getBucketTaggingResult =(GetBucketDomainResult) result;}// If you use the Kotlin language to call this, please note that the exception in the callback method is nullable; otherwise, the onFail method will not be called back, that is:// clientException is of type CosXmlClientException? and serviceException is of type CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
Parameter | Description | API Type |
x-cos-domain-txt-verification | Endpoint verification information. This field is an MD5 checksum of a character string in the format: cos[Region][BucketName-APPID][BucketCreateTime], where `Region` is the bucket region and `BucketCreateTime` is the time the bucket was created in GMT format | String |
// Bucket name in the format of `BucketName-APPID` (`APPID` is required), which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.String bucket = "examplebucket-1250000000";DeleteBucketDomainRequest deleteBucketDomainRequest =new DeleteBucketDomainRequest(bucket);cosXmlService.deleteBucketDomainAsync(deleteBucketDomainRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {// For detailed fields, see the API documentation or SDK source code.DeleteBucketDomainResult deleteBucketDomainResult =(DeleteBucketDomainResult) result;}// If you use the Kotlin language to call this, please note that the exception in the callback method is nullable; otherwise, the onFail method will not be called back, that is:// clientException is of type CosXmlClientException? and serviceException is of type CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
Apakah halaman ini membantu?