API | Operation | Description |
Setting cross-bucket replication | Sets a cross-bucket replication rule for a bucket | |
Querying cross-bucket replication | Queries the cross-bucket replication rule of a bucket | |
Deleting cross-bucket replication | Deletes a cross-bucket replication rule of a bucket |
// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";string ownerUin = "100000000001"; //Replication initiator identifier: OwnerUinstring subUin = "100000000001"; //Replication initiator identifier: SubUinPutBucketReplicationRequest request = new PutBucketReplicationRequest(bucket);// Set replicationPutBucketReplicationRequest.RuleStruct ruleStruct =new PutBucketReplicationRequest.RuleStruct();ruleStruct.id = "replication_01"; // Identifies the replication ruleruleStruct.isEnable = true; // Indicates whether the rule is enabled. true: enabled; false: not enabledruleStruct.appid = "1250000000"; //APPIDruleStruct.region = "ap-beijing"; // Destination bucket regionruleStruct.bucket = "destinationbucket-1250000000"; // Format: BucketName-APPIDruleStruct.prefix = "34"; // Prefix matching policyList<PutBucketReplicationRequest.RuleStruct> ruleStructs =new List<PutBucketReplicationRequest.RuleStruct>();ruleStructs.Add(ruleStruct);request.SetReplicationConfiguration(ownerUin, subUin, ruleStructs);try{PutBucketReplicationResult result = cosXml.PutBucketReplication(request);Console.WriteLine(result.GetResultInfo());}catch (COSXML.CosException.CosClientException clientEx){Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";GetBucketReplicationRequest request = new GetBucketReplicationRequest(bucket);try{GetBucketReplicationResult result = cosXml.GetBucketReplication(request);// Bucket cross-region replication configurationReplicationConfiguration conf = result.replicationConfiguration;}catch (COSXML.CosException.CosClientException clientEx){Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";DeleteBucketReplicationRequest request = new DeleteBucketReplicationRequest(bucket);try{DeleteBucketReplicationResult result = cosXml.DeleteBucketReplication(request);Console.WriteLine(result.GetResultInfo());}catch (COSXML.CosException.CosClientException clientEx){Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
Was this page helpful?