API | 操作名 | 操作描述 |
查询对象列表 | 查询存储桶下的部分或者全部对象 | |
查询对象及其历史版本列表 | 查询存储桶下的部分或者全部对象及其历史版本信息 |
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";GetBucketRequest request = new GetBucketRequest(bucket);//执行请求GetBucketResult result = cosXml.GetBucket(request);//bucket的相关信息ListBucket info = result.listBucket;if (info.isTruncated) {// 数据被截断,记录下数据下标this.nextMarker = info.nextMarker;}}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";GetBucketRequest request = new GetBucketRequest(bucket);//上一次拉取数据的下标request.SetMarker(this.nextMarker);//执行请求GetBucketResult result = cosXml.GetBucket(request);//bucket的相关信息ListBucket info = result.listBucket;}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";GetBucketRequest request = new GetBucketRequest(bucket);//获取 a/ 下的对象以及子目录request.SetPrefix("a/");request.SetDelimiter("/");//执行请求GetBucketResult result = cosXml.GetBucket(request);//bucket的相关信息ListBucket info = result.listBucket;// 对象列表List<ListBucket.Contents> objects = info.contentsList;// 子目录列表List<ListBucket.CommonPrefixes> subDirs = info.commonPrefixesList;}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";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());}
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";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());}
本页内容是否解决了您的问题?