API | Operation | Description |
Querying objects | Queries some or all the objects in a bucket. | |
Querying objects and their version history | Queries some or all the objects in a bucket and their version history. |
try{// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";GetBucketRequest request = new GetBucketRequest(bucket);// Execute the requestGetBucketResult result = cosXml.GetBucket(request);// Bucket informationListBucket info = result.listBucket;if (info.isTruncated) {// The data is truncated, and the next marker of the data is recorded.this.nextMarker = info.nextMarker;}}catch (COSXML.CosException.CosClientException clientEx){// Request failedConsole.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){// Request failedConsole.WriteLine("CosServerException: " + serverEx.GetInfo());}
try{// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";GetBucketRequest request = new GetBucketRequest(bucket);// Use the “nextMarker” from the previous requestrequest.SetMarker(this.nextMarker);// Execute the requestGetBucketResult result = cosXml.GetBucket(request);// Bucket informationListBucket info = result.listBucket;}catch (COSXML.CosException.CosClientException clientEx){// Request failedConsole.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){// Request failedConsole.WriteLine("CosServerException: " + serverEx.GetInfo());}
try{// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";GetBucketRequest request = new GetBucketRequest(bucket);// Get the objects and subdirectories under “a/”request.SetPrefix("a/");request.SetDelimiter("/");// Execute the requestGetBucketResult result = cosXml.GetBucket(request);// Bucket informationListBucket info = result.listBucket;// List objectsList<ListBucket.Contents> objects = info.contentsList;// List common prefixesList<ListBucket.CommonPrefixes> subDirs = info.commonPrefixesList;}catch (COSXML.CosException.CosClientException clientEx){// Request failedConsole.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){// Request failedConsole.WriteLine("CosServerException: " + serverEx.GetInfo());}
try{// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";ListBucketVersionsRequest request = new ListBucketVersionsRequest(bucket);// Execute the requestListBucketVersionsResult result = cosXml.ListBucketVersions(request);// Bucket informationListBucketVersions info = result.listBucketVersions;List<ListBucketVersions.Version> objects = info.objectVersionList;List<ListBucketVersions.CommonPrefixes> prefixes = info.commonPrefixesList;if (info.isTruncated) {// The data is truncated, and the next marker of the data is recorded.this.keyMarker = info.nextKeyMarker;this.versionIdMarker = info.nextVersionIdMarker;}}catch (COSXML.CosException.CosClientException clientEx){// Request failedConsole.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){// Request failedConsole.WriteLine("CosServerException: " + serverEx.GetInfo());}
try{// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";ListBucketVersionsRequest request = new ListBucketVersionsRequest(bucket);// Use the “nextMarker” from the previous requestrequest.SetKeyMarker(this.keyMarker);request.SetVersionIdMarker(this.versionIdMarker);// Execute the requestListBucketVersionsResult result = cosXml.ListBucketVersions(request);ListBucketVersions info = result.listBucketVersions;if (info.isTruncated) {// The data is truncated, and the next marker of the data is recorded.this.keyMarker = info.nextKeyMarker;this.versionIdMarker = info.nextVersionIdMarker;}}catch (COSXML.CosException.CosClientException clientEx){// Request failedConsole.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){// Request failedConsole.WriteLine("CosServerException: " + serverEx.GetInfo());}
Apakah halaman ini membantu?