API | Operation | Description |
Setting bucket referer configuration | Sets a bucket referer allowlist or blocklist | |
Querying bucket referer configuration | Queries a bucket referer allowlist or blocklist |
QCloudPutBucketRefererRequest* request = [QCloudPutBucketRefererRequest new];// Hotlink protection type. Enumerated values: `Black-List`, `White-List`request.refererType = QCloudBucketRefererTypeBlackList;// Whether to enable hotlink protection. Enumerated values: `Enabled`, `Disabled`request.status = QCloudBucketRefererStatusEnabled;// Whether to allow access with an empty referer. Enumerated values: `Allow`, `Deny` (default)request.configuration = QCloudBucketRefererConfigurationDeny;// List of domain names in the blocklist/allowlist. Using a prefix to specify multiple domains is supported. Domain names and IPs with ports are supported. A wildcard (*) is supported for second-level or multi-level domains.request.domainList = @[@"*.com",@"*.qq.com"];// Bucket name in the format of `BucketName-APPID`request.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(id outputObject, NSError *error) {if (error){// Failed to add hotlink protection}else{// Failed to add hotlink protection}}];[[QCloudCOSXMLService defaultCOSXML] PutBucketReferer:request];
let request = QCloudPutBucketRefererRequest.init();// Hotlink protection type. Enumerated values: `Black-List`, `White-List`request.refererType = QCloudBucketRefererType.blackList;// Whether to enable hotlink protection. Enumerated values: `Enabled`, `Disabled`request.status = QCloudBucketRefererStatus.enabled;// Whether to allow access with an empty referer. Enumerated values: `Allow`, `Deny` (default)request.configuration = QCloudBucketRefererConfiguration.allow;// List of domain names in the blocklist/allowlist. Using a prefix to specify multiple domains is supported. Domain names and IPs with ports are supported. A wildcard (*) is supported for second-level or multi-level domains.request.domainList = ["*.com","*.qq.com"];// Bucket name in the format of `BucketName-APPID`request.bucket = "examplebucket-1250000000";request.finishBlock = {(result,error) inif (error != nil){// Failed to add hotlink protection}else{// Failed to add hotlink protection}}QCloudCOSXMLService.defaultCOSXML().putBucketReferer(request);
QCloudGetBucketRefererRequest* request = [QCloudGetBucketRefererRequest new];// Bucket name in the format of `BucketName-APPID`request.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(QCloudBucketRefererInfo * outputObject, NSError *error) {// Hotlink protection obtained by the `outputObject` request. For field details, see the API documentation or SDK source code.// Class of `QCloudBucketRefererInfo`}];[[QCloudCOSXMLService defaultCOSXML] GetBucketReferer:request];
let request = QCloudGetBucketRefererRequest.init();// Bucket name in the format of `BucketName-APPID`request.bucket = "examplebucket-1250000000";request.finishBlock = {(result,error) in// Hotlink protection obtained by the `outputObject` request. For field details, see the API documentation or SDK source code.// Class of `QCloudBucketRefererInfo`}QCloudCOSXMLService.defaultCOSXML().getBucketReferer(request);
Apakah halaman ini membantu?