API | Operation | Description |
Setting a cross-region replication rule | Sets a cross-region replication rule for a bucket | |
Querying a cross-region replication rule | Queries the cross-region replication rule of a bucket | |
Deleting a cross-region replication rule | Deletes the cross-region replication rule from a bucket |
QCloudPutBucketReplicationRequest* request = [[QCloudPutBucketReplicationRequest alloc] init];// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";// All cross-region replication configuration informationQCloudBucketReplicationConfiguation* replConfiguration =[[QCloudBucketReplicationConfiguation alloc] init];// Initiator IDreplConfiguration.role = @"qcs::cam::uin/100000000001:uin/100000000001";// Specific configuration informationQCloudBucketReplicationRule* rule = [[QCloudBucketReplicationRule alloc] init];// Identify the name of a specific rulerule.identifier = @"identifier";rule.status = QCloudCOSXMLStatusEnabled;// Resource IDQCloudBucketReplicationDestination* destination = [[QCloudBucketReplicationDestination alloc] init];NSString* destinationBucket = @"destinationbucket-1250000000";// Destination bucket regionNSString* region = @"ap-beijing";destination.bucket = [NSString stringWithFormat:@"qcs::cos:%@::%@",region,destinationBucket];// Destination bucket informationrule.destination = destination;// Prefix matching policy. Policies cannot overlap; otherwise, an error will be returned. The prefix matching root directory is emptyrule.prefix = @"prefix1";replConfiguration.rule = @[rule];request.configuation = replConfiguration;[request setFinishBlock:^(id outputObject, NSError* error) {// `outputObject` contains all the HTTP response headersNSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutBucketRelication:request];
let putBucketReplication = QCloudPutBucketReplicationRequest.init();// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketputBucketReplication.bucket = "examplebucket-1250000000";// All cross-region replication configuration informationlet config = QCloudBucketReplicationConfiguation.init();config.role = "qcs::cam::uin/100000000001:uin/100000000001";// Initiator IDlet rule = QCloudBucketReplicationRule.init();// Identify the name of a specific rulerule.identifier = "rule1";// Indicate whether the rule is enabled. Valid values: .enabled, .disabledrule.status = .enabled;// Destination bucket informationlet destination = QCloudBucketReplicationDestination.init();let destinationBucket = "destinationbucket-1250000000";let region = "ap-beijing";destination.bucket = "qcs::cos:\\(region)::\\(destinationBucket)";rule.destination = destination;// Prefix matching policy. Policies cannot overlap; otherwise, an error will be returned. The prefix matching root directory is emptyrule.prefix = "dir/";config.rule = [rule];putBucketReplication.configuation = config;putBucketReplication.finishBlock = {(result,error) inif let result = result {// "result" contains response headers.} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putBucketRelication(putBucketReplication);
QCloudGetBucketReplicationRequest* request = [[QCloudGetBucketReplicationRequest alloc] init];// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(QCloudBucketReplicationConfiguation* result,NSError* error) {// Specific configuration information. A maximum of 1,000 rules are supported. All rules must be directed to one destination bucket.NSArray *rules = result.rule;}];[[QCloudCOSXMLService defaultCOSXML] GetBucketReplication:request];
let getBucketReplication = QCloudGetBucketReplicationRequest.init();getBucketReplication.bucket = "examplebucket-1250000000";getBucketReplication.setFinish { (config, error) inif let config = config {// List all the ruleslet rule = config.rule} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucketReplication(getBucketReplication);
QCloudDeleteBucketReplicationRequest* request =[[QCloudDeleteBucketReplicationRequest alloc] init];// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(id outputObject, NSError* error) {// `outputObject` contains all the HTTP response headersNSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] DeleteBucketReplication:request];
let deleteBucketReplication = QCloudDeleteBucketReplicationRequest.init();deleteBucketReplication.bucket = "examplebucket-1250000000";deleteBucketReplication.finishBlock = {(result,error) inif let result = result {// "result" contains response headers.} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().deleteBucketReplication(deleteBucketReplication);
Apakah halaman ini membantu?