예제 #1
0
        /// 获取对象多版本列表第一页数据
        public void ListObjectsVersioning()
        {
            //.cssg-snippet-body-start:[list-objects-versioning]
            try
            {
                string bucket = "examplebucket-1250000000"; //格式:BucketName-APPID
                ListBucketVersionsRequest request = new ListBucketVersionsRequest(bucket);
                //执行请求
                ListBucketVersionsResult result = cosXml.ListBucketVersions(request);
                //bucket的相关信息
                ListBucketVersions info = result.listBucketVersions;

                List <ListBucketVersions.Version>        objects  = info.objectVersionList;
                List <ListBucketVersions.CommonPrefixes> prefixes = info.commonPrefixesList;

                if (info.isTruncated)
                {
                    // 数据被截断,记录下数据下标
                    this.keyMarker       = info.nextKeyMarker;
                    this.versionIdMarker = info.nextVersionIdMarker;
                }
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                //请求失败
                Console.WriteLine("CosClientException: " + clientEx);
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                //请求失败
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
            }
            //.cssg-snippet-body-end
        }
예제 #2
0
        /// 获取对象多版本列表下一页数据
        public void ListObjectsVersioningNextPage()
        {
            //.cssg-snippet-body-start:[list-objects-versioning-next-page]
            try
            {
                string bucket = "examplebucket-1250000000"; //格式:BucketName-APPID
                ListBucketVersionsRequest request = new ListBucketVersionsRequest(bucket);

                // 上一页的数据结束下标
                request.SetKeyMarker(this.keyMarker);
                request.SetVersionIdMarker(this.versionIdMarker);

                //执行请求
                ListBucketVersionsResult result = cosXml.ListBucketVersions(request);
                ListBucketVersions       info   = result.listBucketVersions;

                if (info.isTruncated)
                {
                    // 数据被截断,记录下数据下标
                    this.keyMarker       = info.nextKeyMarker;
                    this.versionIdMarker = info.nextVersionIdMarker;
                }
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                //请求失败
                Console.WriteLine("CosClientException: " + clientEx);
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                //请求失败
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
            }
            //.cssg-snippet-body-end
        }
예제 #3
0
        public static void AsynListBucketVersions(COSXML.CosXml cosXml, string bucket)
        {
            ListBucketVersionsRequest request = new ListBucketVersionsRequest(bucket);

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

            //执行请求
            cosXml.ListBucketVersions(request,
                                      delegate(CosResult cosResult)
            {
                ListBucketVersionsResult result = cosResult as ListBucketVersionsResult;
                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());
                }
            });
        }
예제 #4
0
        public static void ListBucketVersions(COSXML.CosXml cosXml, string bucket)
        {
            try
            {
                ListBucketVersionsRequest request = new ListBucketVersionsRequest(bucket);
                //设置签名有效时长
                request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600);
                //执行请求
                ListBucketVersionsResult result = cosXml.ListBucketVersions(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());
            }
        }
예제 #5
0
 public void ListBucketVersions(ListBucketVersionsRequest request, Callback.OnSuccessCallback <CosResult> successCallback, Callback.OnFailedCallback failCallback)
 {
     Schedue(request, new ListBucketVersionsResult(), successCallback, failCallback);
 }
예제 #6
0
 public ListBucketVersionsResult ListBucketVersions(ListBucketVersionsRequest request)
 {
     return((Model.Bucket.ListBucketVersionsResult)Excute(request, new Model.Bucket.ListBucketVersionsResult()));
 }
        public void ListBucketVersions()
        {
            try
            {
                var service = QCloudServer.Instance().NewService(QCloudServer.Instance().regionForBucketVersioning);

                ListBucketVersionsRequest request = new ListBucketVersionsRequest(QCloudServer.Instance().bucketVersioning);
                request.SetDelimiter("/");
                request.SetEncodingType("url");
                request.SetMaxKeys("500");

                //执行请求
                ListBucketVersionsResult result = service.ListBucketVersions(request);

                Assert.True(result.httpCode == 200);
                // Console.WriteLine(result.GetResultInfo());
                Assert.IsNotEmpty((result.GetResultInfo()));

                var listObjects = result.listBucketVersions;

                Assert.NotNull(listObjects.delimiter);
                Assert.NotNull(listObjects.encodingType);
                Assert.NotNull(listObjects.name);
                Assert.NotZero(listObjects.maxKeys);
                Assert.IsFalse(listObjects.isTruncated);

                Assert.That(listObjects.prefix, Is.Null.Or.Empty);
                Assert.That(listObjects.keyMarker, Is.Null.Or.Empty);
                Assert.That(listObjects.versionIdMarker, Is.Null.Or.Empty);
                Assert.That(listObjects.nextVersionIdMarker, Is.Null.Or.Empty);
                Assert.That(listObjects.nextKeyMarker, Is.Null.Or.Empty);

                Assert.NotZero(listObjects.commonPrefixesList.Count);
                foreach (var commonPrefix in listObjects.commonPrefixesList)
                {
                    Assert.NotNull(commonPrefix.prefix);
                }

                Assert.NotZero(listObjects.objectVersionList.Count);
                foreach (var content in listObjects.objectVersionList)
                {
                    Assert.NotNull(content.eTag);
                    Assert.NotNull(content.owner);
                    Assert.NotNull(content.owner.uid);
                    Assert.NotNull(content.owner.displayName);
                    Assert.NotNull(content.key);
                    Assert.NotNull(content.lastModified);
                    Assert.NotNull(content.size);
                    Assert.NotNull(content.storageClass);
                    Assert.NotNull(content.versionId);
                    Assert.NotNull(content.isLatest);
                }

                Assert.NotZero(listObjects.deleteMarkers.Count);
                foreach (var content in listObjects.deleteMarkers)
                {
                    Assert.NotNull(content.owner);
                    Assert.NotNull(content.owner.uid);
                    Assert.NotNull(content.owner.displayName);
                    Assert.NotNull(content.key);
                    Assert.NotNull(content.lastModified);
                    Assert.NotNull(content.versionId);
                    Assert.NotNull(content.isLatest);
                }
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                Console.WriteLine("CosClientException: " + clientEx.Message);
                Assert.Fail();
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
                Assert.Fail();
            }
        }