API | 操作名 | 操作描述 |
PUT Bucket domain | 设置自定义域名 | 设置存储桶的自定义域名信息 |
GET Bucket domain | 查询自定义域名 | 查询存储桶的自定义域名信息 |
QCloudPutBucketDomainRequest *req = [QCloudPutBucketDomainRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketreq.bucket = @"examplebucket-1250000000";QCloudDomainConfiguration *config = [QCloudDomainConfiguration new];QCloudDomainRule *rule = [QCloudDomainRule new];// 源站状态,可选 QCloudDomainStatueEnabled、 QCloudDomainStatueDisabledrule.status = QCloudDomainStatueEnabled;// 域名信息rule.name = @"www.baidu.com";// 替换已存在的配置、有效值CNAME/TXT 填写则强制校验域名所有权之后,再下发配置rule.replace = QCloudCOSDomainReplaceTypeTxt;rule.type = QCloudCOSDomainTypeRest;// 规则描述集合的数组config.rules = @[rule];// 域名配置的规则req.domain = config;[req setFinishBlock:^(id outputObject, NSError *error) {// outputObject 包含所有的响应 http 头部NSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML]PutBucketDomain:req];
let req = QCloudPutBucketDomainRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";let config = QCloudDomainConfiguration.init();let rule = QCloudDomainRule.init();// 开启状态,可选 .enabled, .disabledrule.status = .enabled;rule.name = "www.baidu.com";// 替换已存在的配置、有效值CNAME/TXT 填写则强制校验域名所有权之后,再下发配置rule.replace = .txt;rule.type = .rest;// 规则描述集合的数组config.rules = [rule];// 域名配置的规则req.domain = config;req.finishBlock = {(result,error) inif let result = result {// result 包含响应的 header 信息} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putBucketDomain(req);
状态码 | 说明 |
HTTP 409 Conflict | 该域名记录已存在,且请求中没有设置强制覆盖。或者该域名记录不存在,且请求中设置了强制覆盖 |
HTTP 451 Unavailable For Legal Reasons | 该域名是中国境内域名,并且没有备案 |
QCloudGetBucketDomainRequest *getReq = [QCloudGetBucketDomainRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketgetReq.bucket = @"examplebucket-1250000000";[getReq setFinishBlock:^(QCloudDomainConfiguration * _Nonnull result,NSError * _Nonnull error) {// 规则描述集合的数组NSArray *rules = result.rules;}];[[QCloudCOSXMLService defaultCOSXML]GetBucketDomain:getReq];
let req = QCloudGetBucketDomainRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";req.finishBlock = {(result,error) inif let result = result {// result 包含源站信息} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucketDomain(req);
参数名称 | 描述 | 类型 |
x-cos-domain-txt-verification | 域名校验信息,该字段是一个 MD5 校验值,原串格式为: cos[Region][BucketName-APPID][BucketCreateTime] ,其中 Region 为存储桶所在地域,BucketCreateTime 为存储桶 GMT 创建时间 | String |
本页内容是否解决了您的问题?