Ejemplo n.º 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
        }
Ejemplo n.º 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
        }
 internal override void ParseResponseBody(System.IO.Stream inputStream, string contentType, long contentLength)
 {
     listBucketVersions = new ListBucketVersions();
     XmlParse.ParseListBucketVersions(inputStream, listBucketVersions);
 }