Example #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
        }