API | Operation | Description |
PUT Bucket domain | Setting a custom domain | Sets a custom domain for a bucket |
GET Bucket domain | Querying a custom domain | Queries the custom domain of a bucket |
QCloudPutBucketDomainRequest *req = [QCloudPutBucketDomainRequest new];// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketreq.bucket = @"examplebucket-1250000000";QCloudDomainConfiguration *config = [QCloudDomainConfiguration new];QCloudDomainRule *rule = [QCloudDomainRule new];// Origin server status. Valid values: QCloudDomainStatueEnabled; QCloudDomainStatueDisabledrule.status = QCloudDomainStatueEnabled;// Domain informationrule.name = @"www.baidu.com";// Replace the existing configuration. If CNAME/TXT is specified as a valid value, the new configuration won’t be delivered until verification of endpoint ownership is completerule.replace = QCloudCOSDomainReplaceTypeTxt;rule.type = QCloudCOSDomainTypeRest;// Array of rule descriptionsconfig.rule = @[rule];// Domain configuration rulereq.domain = config;[request setFinishBlock:^(id outputObject, NSError* error) {// `outputObject` contains all the HTTP response headersNSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML]PutBucketDomain:req];
let req = QCloudPutBucketDomainRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";let config = QCloudDomainConfiguration.init();let rule = QCloudDomainRule.init();// Indicate whether the rule is enabled. Valid values: .enabled; .disabledrule.status = .enabled;rule.name = "www.baidu.com";// Replace the existing configuration. If CNAME/TXT is specified as a valid value, the new configuration won’t be delivered until verification of endpoint ownership is completerule.replace = .txt;rule.type = .rest;// Array of rule descriptionsconfig.rules = [rule];// Domain configuration rulereq.domain = config;req.finishBlock = {(result,error) inif let result = result {// result contains response headers} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putBucketDomain(req);
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 |
QCloudGetBucketDomainRequest *getReq = [QCloudGetBucketDomainRequest new];// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketgetReq.bucket = @"examplebucket-1250000000";[getReq setFinishBlock:^(QCloudDomainConfiguration * _Nonnull result,NSError * _Nonnull error) {// Array of rule descriptionsNSArray *rules = result.rules;}];[[QCloudCOSXMLService defaultCOSXML]GetBucketDomain:getReq];
let req = QCloudGetBucketDomainRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";req.finishBlock = {(result,error) inif let result = result {// result contains origin server information} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucketDomain(req);
Parameter Name | Description | 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 |
Was this page helpful?