Пример #1
0
        public static void AsynGetBucketReplication(COSXML.CosXml cosXml, string bucket)
        {
            GetBucketReplicationRequest request = new GetBucketReplicationRequest(bucket);

            //设置签名有效时长
            request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600);


            ///执行请求
            cosXml.GetBucketReplication(request,
                                        delegate(CosResult cosResult)
            {
                GetBucketReplicationResult result = cosResult as GetBucketReplicationResult;
                Console.WriteLine(result.GetResultInfo());
            },
                                        delegate(CosClientException clientEx, CosServerException serverEx)
            {
                if (clientEx != null)
                {
                    QLog.D("XIAO", clientEx.Message);
                    Console.WriteLine("CosClientException: " + clientEx.Message);
                }
                if (serverEx != null)
                {
                    QLog.D("XIAO", serverEx.Message);
                    Console.WriteLine("CosServerException: " + serverEx.GetInfo());
                }
            });
        }
        private static async Task RetrieveReplicationConfigurationAsync(IAmazonS3 client)
        {
            // Retrieve the configuration.
            GetBucketReplicationRequest getRequest = new GetBucketReplicationRequest
            {
                BucketName = sourceBucket
            };
            GetBucketReplicationResponse getResponse = await client.GetBucketReplicationAsync(getRequest);

            // Print.
            Console.WriteLine("Printing replication configuration information...");
            Console.WriteLine("Role ARN: {0}", getResponse.Configuration.Role);
            foreach (var rule in getResponse.Configuration.Rules)
            {
                Console.WriteLine("ID: {0}", rule.Id);
                Console.WriteLine("Prefix: {0}", rule.Prefix);
                Console.WriteLine("Status: {0}", rule.Status);
            }
        }
Пример #3
0
        public void getBucketReplication()
        {
            //.cssg-snippet-body-start:[get-bucket-replication]
            CosXmlConfig config = new CosXmlConfig.Builder()
                                  .SetConnectionTimeoutMs(60000) //设置连接超时时间,单位毫秒,默认45000ms
                                  .SetReadWriteTimeoutMs(40000)  //设置读写超时时间,单位毫秒,默认45000ms
                                  .IsHttps(true)                 //设置默认 HTTPS 请求
                                  .SetAppid("1253653367")        //设置腾讯云账户的账户标识 APPID
                                  .SetRegion("ap-guangzhou")     //设置一个默认的存储桶地域
                                  .Build();

            string secretId       = Environment.GetEnvironmentVariable("COS_KEY");    //云 API 密钥 SecretId
            string secretKey      = Environment.GetEnvironmentVariable("COS_SECRET"); //云 API 密钥 SecretKey
            long   durationSecond = 600;                                              //每次请求签名有效时长,单位为秒
            QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
                                                                                                    secretKey, durationSecond);

            CosXml cosXml = new CosXmlServer(config, qCloudCredentialProvider);

            string bucket = "bucket-cssg-test-dotnet-1253653367"; //格式:BucketName-APPID
            GetBucketReplicationRequest request = new GetBucketReplicationRequest(bucket);

            //使用同步方法
            try
            {
                GetBucketReplicationResult result = cosXml.GetBucketReplication(request);
                // 存储桶的跨区域复制配置
                ReplicationConfiguration conf = result.replicationConfiguration;
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                Console.WriteLine("CosClientException: " + clientEx);
                Assert.Null(clientEx);
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
                Assert.Null(serverEx);
            }
            //.cssg-snippet-body-end
        }
Пример #4
0
        private void GetBucketReplication()
        {
            try
            {
                GetBucketReplicationRequest request = new GetBucketReplicationRequest(bucket);


                //执行请求
                GetBucketReplicationResult result = cosXml.GetBucketReplication(request);
                var replication = result.replicationConfiguration;

                // Console.WriteLine(result.GetResultInfo());
                Assert.IsNotEmpty((result.GetResultInfo()));

                Assert.AreEqual(result.httpCode, 200);

                Assert.NotNull(replication.role);
                Assert.NotZero(replication.rules.Count);

                Assert.NotNull(replication.rules[0].id);
                Assert.NotNull(replication.rules[0].prefix);
                Assert.AreEqual(replication.rules[0].status, "Enabled");

                Assert.NotNull(replication.rules[0].destination);
                Assert.NotNull(replication.rules[0].destination.bucket);
                Assert.NotNull(replication.rules[0].destination.storageClass);
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                Console.WriteLine("CosClientException: " + clientEx.Message);
                Assert.Fail();
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
                Assert.Fail();
            }
        }
Пример #5
0
        public static void GetBucketReplication(COSXML.CosXml cosXml, string bucket)
        {
            try
            {
                GetBucketReplicationRequest request = new GetBucketReplicationRequest(bucket);
                //设置签名有效时长
                request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600);
                //执行请求
                GetBucketReplicationResult result = cosXml.GetBucketReplication(request);

                Console.WriteLine(result.GetResultInfo());
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                QLog.D("XIAO", clientEx.Message);
                Console.WriteLine("CosClientException: " + clientEx.Message);
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                QLog.D("XIAO", serverEx.Message);
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
            }
        }
Пример #6
0
        /// 获取存储桶跨地域复制规则
        public void GetBucketReplication()
        {
            //.cssg-snippet-body-start:[get-bucket-replication]
            string bucket = "examplebucket-1250000000"; //格式:BucketName-APPID
            GetBucketReplicationRequest request = new GetBucketReplicationRequest(bucket);

            try
            {
                GetBucketReplicationResult result = cosXml.GetBucketReplication(request);
                // 存储桶的跨区域复制配置
                ReplicationConfiguration conf = result.replicationConfiguration;
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                Console.WriteLine("CosClientException: " + clientEx);
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
            }

            //.cssg-snippet-body-end
        }
Пример #7
0
 public void GetBucketReplication(GetBucketReplicationRequest request, Callback.OnSuccessCallback <CosResult> successCallback, Callback.OnFailedCallback failCallback)
 {
     Schedue(request, new GetBucketReplicationResult(), successCallback, failCallback);
 }
Пример #8
0
 public GetBucketReplicationResult GetBucketReplication(GetBucketReplicationRequest request)
 {
     return((Model.Bucket.GetBucketReplicationResult)Excute(request, new Model.Bucket.GetBucketReplicationResult()));
 }
Пример #9
0
 public Task <GetBucketReplicationResponse> GetBucketReplicationAsync(GetBucketReplicationRequest request, CancellationToken cancellationToken = default)
 {
     throw new NotImplementedException();
 }
Пример #10
0
 /// <summary>
 /// 获取桶的跨区域复制配置。
 /// </summary>
 /// <param name="request">获取桶跨区域复制配置的请求参数。</param>
 /// <returns>获取桶跨区域复制配置的响应结果。</returns>
 public GetBucketReplicationResponse GetBucketReplication(GetBucketReplicationRequest request)
 {
     return(this.DoRequest <GetBucketReplicationRequest, GetBucketReplicationResponse>(request));
 }
 /// <summary>
 /// Start the asynchronous request for obtaining the cross-region replication configuration of a bucket.
 /// </summary>
 /// <param name="request">Parameters in a request for obtaining the cross-region replication configuration of a bucket</param>
 /// <param name="callback">Asynchronous request callback function</param>
 /// <param name="state">Asynchronous request status object</param>
 /// <returns>Response to the asynchronous request</returns>
 public IAsyncResult BeginGetBucketReplication(GetBucketReplicationRequest request, AsyncCallback callback, object state)
 {
     return(this.BeginDoRequest <GetBucketReplicationRequest>(request, callback, state));
 }
Пример #12
0
 public void GetBucketReplicationAsync(GetBucketReplicationRequest request, AmazonServiceCallback <GetBucketReplicationRequest, GetBucketReplicationResponse> callback, AsyncOptions options = null)
 {
     throw new System.NotImplementedException();
 }