Exemple #1
0
        public static void AsynGetBucketACL(COSXML.CosXml cosXml, string bucket)
        {
            GetBucketACLRequest request = new GetBucketACLRequest(bucket);

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

            ///执行请求
            cosXml.GetBucketACL(request,
                                delegate(CosResult cosResult)
            {
                GetBucketACLResult result = cosResult as GetBucketACLResult;
                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());
                }
            });
        }
Exemple #2
0
 public static void GetBucketACL(COSXML.CosXml cosXml, string bucket)
 {
     try
     {
         GetBucketACLRequest request = new GetBucketACLRequest(bucket);
         //设置签名有效时长
         request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600);
         //执行请求
         GetBucketACLResult result = cosXml.GetBucketACL(request);
         Console.WriteLine(result.GetResultInfo());
     }
     catch (COSXML.CosException.CosClientException clientEx)
     {
         QLog.D("XIAO", clientEx.Message);
         Console.WriteLine("CosClientException: " + clientEx.StackTrace);
     }
     catch (COSXML.CosException.CosServerException serverEx)
     {
         QLog.D("XIAO", serverEx.Message);
         Console.WriteLine("CosServerException: " + serverEx.GetInfo());
     }
 }
Exemple #3
0
        private void GetBucketACL()
        {
            try
            {
                GetBucketACLRequest request = new GetBucketACLRequest(bucket);

                //执行请求
                GetBucketACLResult result = cosXml.GetBucketACL(request);

                AccessControlPolicy acl = result.accessControlPolicy;

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

                Assert.AreEqual(result.httpCode, 200);
                Assert.NotNull(acl.owner);
                Assert.NotNull(acl.owner.id);
                Assert.NotNull(acl.owner.displayName);
                Assert.NotNull(acl.accessControlList);
                Assert.NotNull(acl.accessControlList.grants);
                Assert.NotZero(acl.accessControlList.grants.Count);
                Assert.NotNull(acl.accessControlList.grants[0].permission);
                Assert.NotNull(acl.accessControlList.grants[0].grantee);
                Assert.NotNull(acl.accessControlList.grants[0].grantee.id);
                Assert.NotNull(acl.accessControlList.grants[0].grantee.displayName);
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                Console.WriteLine("CosClientException: " + clientEx.StackTrace);
                Assert.Fail();
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
                Assert.Fail();
            }
        }