API | Operation | Description |
Setting cross-region replication rule | Sets a cross-region replication rule for a bucket | |
Querying cross-region replication rule | Queries the cross-region replication rule of a bucket | |
Deleting cross-region replication rule | Deletes a cross-region replication rule from a bucket |
String bucket = "examplebucket-1250000000"; // Format: BucketName-APPIDstring 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"; // Identify 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());}
String bucket = "examplebucket-1250000000"; // Format: BucketName-APPIDGetBucketReplicationRequest request = new GetBucketReplicationRequest(bucket);try{GetBucketReplicationResult result = cosXml.GetBucketReplication(request);// Bucket’s 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());}
String bucket = "examplebucket-1250000000"; // Format: BucketName-APPIDDeleteBucketReplicationRequest 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?