tencent cloud

masukan

Cross-Bucket Replication

Terakhir diperbarui:2024-02-02 14:36:36

    Overview

    This document provides an overview of APIs and SDK code samples related to bucket copying.
    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

    Setting Cross-Bucket Replication

    API description

    This API is used to set a cross-bucket replication rule for a bucket.

    Sample code

    // 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: OwnerUin
    string subUin = "100000000001"; //Replication initiator identifier: SubUin
    PutBucketReplicationRequest request = new PutBucketReplicationRequest(bucket);
    // Set replication
    PutBucketReplicationRequest.RuleStruct ruleStruct =
    new PutBucketReplicationRequest.RuleStruct();
    ruleStruct.id = "replication_01"; // Identifies the replication rule
    ruleStruct.isEnable = true; // Indicates whether the rule is enabled. true: enabled; false: not enabled
    ruleStruct.appid = "1250000000"; //APPID
    ruleStruct.region = "ap-beijing"; // Destination bucket region
    ruleStruct.bucket = "destinationbucket-1250000000"; // Format: BucketName-APPID
    ruleStruct.prefix = "34"; // Prefix matching policy
    List<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());
    }
    Note:
    For the complete sample, please go to GitHub.

    Querying Cross-Bucket Replication

    API description

    This API is used to query the cross-bucket replication rule of a bucket.

    Sample code

    // 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 configuration
    ReplicationConfiguration conf = result.replicationConfiguration;
    }
    catch (COSXML.CosException.CosClientException clientEx)
    {
    Console.WriteLine("CosClientException: " + clientEx);
    }
    catch (COSXML.CosException.CosServerException serverEx)
    {
    Console.WriteLine("CosServerException: " + serverEx.GetInfo());
    }
    Note:
    For the complete sample, please go to GitHub.

    Deleting Cross-Bucket Replication

    API description

    This API is used to delete the cross-bucket replication rule set for a bucket.

    Sample code

    // 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());
    }
    Note:
    For the complete sample, please go to GitHub.
    Hubungi Kami

    Hubungi tim penjualan atau penasihat bisnis kami untuk membantu bisnis Anda.

    Dukungan Teknis

    Buka tiket jika Anda mencari bantuan lebih lanjut. Tiket kami tersedia 7x24.

    Dukungan Telepon 7x24