API | Operation | Description |
Querying an object list | Queries some or all objects in a bucket | |
Querying objects and their version history | Queries some or all the objects in a bucket and their version history. |
QCloudGetBucketRequest* request = [QCloudGetBucketRequest new];// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";// Maximum number of objects to return at a time. Default value: 1000request.maxKeys = 100;// Prefix match, which is used to specify the address prefix of the returned filesrequest.prefix = @"dir1/";[request setFinishBlock:^(QCloudListBucketResult * result, NSError* error) {// result contains the request result// `QCloudListBucketResult.contents` is the array of files in the bucket// `QCloudListBucketResult.commonPrefixes` is the array of folders in the bucketif (result.isTruncated) {// The data is truncated, and the next page of data needs to be pulledself->prevPageResult = result;}}];[[QCloudCOSXMLService defaultCOSXML] GetBucket:request];
let getBucketReq = QCloudGetBucketRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketgetBucketReq.bucket = "examplebucket-1250000000";// Maximum number of objects to return at a time. Default value: 1000getBucketReq.maxKeys = 100;// Prefix matchgetBucketReq.prefix = "dir/";getBucketReq.setFinish { (result, error) inif let result = result {// Object listlet contents = result.contentsif (result.isTruncated) {// The data is truncated, and the next page of data needs to be requestedself.prevPageResult = result;}} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucket(getBucketReq);
QCloudGetBucketRequest* request = [QCloudGetBucketRequest new];// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";// prevPageResult is the result returned on the previous page// Paging parameter. By default, entries are listed in UTF-8 binary order starting with the markerrequest.marker = prevPageResult.nextMarker;// Maximum number of objects to return at a time. Default value: 1000request.maxKeys = 100;[request setFinishBlock:^(QCloudListBucketResult * result, NSError* error) {// result contains the request result.// `QCloudListBucketResult.contents` is the array of files in the bucket// `QCloudListBucketResult.commonPrefixes` is the array of folders in the bucketif (result.isTruncated) {// The data is truncated, and the next page of data needs to be pulledself->prevPageResult = result;}}];[[QCloudCOSXMLService defaultCOSXML] GetBucket:request];
let getBucketReq = QCloudGetBucketRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketgetBucketReq.bucket = "examplebucket-1250000000";// Paging parameter. By default, entries are listed in UTF-8 binary order starting with the markerif let result = self.prevPageResult {getBucketReq.marker = result.marker}// Maximum number of objects to return at a time. Default value: 1000getBucketReq.maxKeys = 100;// Prefix matchgetBucketReq.prefix = "dir/";getBucketReq.setFinish { (result, error) inif let result = result {// Object listlet contents = result.contentsif (result.isTruncated) {// The data is truncated, and the next page of data needs to be requestedself.prevPageResult = result;}} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucket(getBucketReq);
QCloudGetBucketRequest* request = [QCloudGetBucketRequest new];// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";// Maximum number of objects to return at a time. Default value: 1000request.maxKeys = 100;// Prefix match, which is used to specify the address prefix of the returned filesrequest.prefix = @"dir1/";// The delimiter is a symbol. If the Prefix exists, identical paths between the Prefix and delimiter will be grouped together,// which is defined as Common Prefix. Then, all common prefixes are listed. If there is no Prefix, the listing starts from the beginning of the path.// delimiter: path separator, which is fixed to `/`request.delimiter = @"/";// prevPageResult is the result returned on the previous page.// Paging parameter. By default, entries are listed in UTF-8 binary order starting with the markerrequest.marker = prevPageResult.nextMarker;[request setFinishBlock:^(QCloudListBucketResult * result, NSError* error) {// result contains the request result// `QCloudListBucketResult.contents` is the array of files in the bucket// `QCloudListBucketResult.commonPrefixes` is the array of folders in the bucketif (result.isTruncated) {// The data is truncated, and the next page of data needs to be pulled.self->prevPageResult = result;}}];[[QCloudCOSXMLService defaultCOSXML] GetBucket:request];
let getBucketReq = QCloudGetBucketRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketgetBucketReq.bucket = "examplebucket-1250000000";// Maximum number of objects to return at a time. Default value: 1000getBucketReq.maxKeys = 100;// Prefix match, which is used to specify the address prefix of the returned filesgetBucketReq.prefix = "dir/";// The delimiter is a symbol. If the Prefix exists, identical paths between the Prefix and delimiter will be grouped together,// which is defined as Common Prefix. Then, all common prefixes are listed. If there is no Prefix, the listing starts from the beginning of the path.// delimiter: path separator, which is always `/`getBucketReq.delimiter = "/";// Paging parameter. By default, entries are listed in UTF-8 binary order starting with the markerif let result = self.prevPageResult {getBucketReq.marker = result.marker}getBucketReq.setFinish { (result, error) inif let result = result {// Object listlet contents = result.contentsif (result.isTruncated) {// The data is truncated, and the next page of data needs to be requestedself.prevPageResult = result;}} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucket(getBucketReq);
QCloudListObjectVersionsRequest* listObjectVersionsRequest = [[QCloudListObjectVersionsRequest alloc] init];// Bucket NamelistObjectVersionsRequest.bucket = @"bucketname";// Number of requested data entries per page. Default value: 1000.listObjectVersionsRequest.maxKeys = 100;// List the unrequested entries from the current keylistObjectVersionsRequest.keyMarker = prevPageResult.nextKeyMarker;// List the unrequested entries from an object version in the current keylistObjectVersionsRequest.versionIdMarker = prevPageResult.nextVersionIDMarkder;[listObjectVersionsRequest setFinishBlock:^(QCloudListVersionsResult * _Nonnull result,NSError * _Nonnull error) {// Deleted filesNSArray<QCloudDeleteMarker*> *deleteMarker = result.deleteMarker;// Number of object version entriesNSArray<QCloudVersionContent*> *versionContent = result.versionContent;if (result.isTruncated) {// The data is truncated, and the next page of data needs to be pulledself->prevPageResult = result;}}];[[QCloudCOSXMLService defaultCOSXML] ListObjectVersions:listObjectVersionsRequest];
Apakah halaman ini membantu?