API | 操作名 | 操作描述 |
查询对象列表 | 查询存储桶下的部分或者全部对象 | |
查询对象及其历史版本列表 | 查询存储桶下的部分或者全部对象及其历史版本信息 |
QCloudGetBucketRequest* request = [QCloudGetBucketRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";// 单次返回的最大条目数量,默认1000request.maxKeys = 100;// 前缀匹配,用来规定返回的文件前缀地址request.prefix = @"dir1/";[request setFinishBlock:^(QCloudListBucketResult * result, NSError* error) {// result 返回具体信息// QCloudListBucketResult.contents 桶内文件数组// QCloudListBucketResult.commonPrefixes 桶内文件夹数组if (result.isTruncated) {// 表示数据被截断,需要拉取下一页数据self->prevPageResult = result;}}];[[QCloudCOSXMLService defaultCOSXML] GetBucket:request];
let getBucketReq = QCloudGetBucketRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketgetBucketReq.bucket = "examplebucket-1250000000";// 单次返回的最大条目数量,默认1000getBucketReq.maxKeys = 100;// 前缀匹配getBucketReq.prefix = "dir/";getBucketReq.setFinish { (result, error) inif let result = result {// 文件列表let contents = result.contentsif (result.isTruncated) {// 数据被截断,需要请求下一页数据self.prevPageResult = result;}} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucket(getBucketReq);
QCloudGetBucketRequest* request = [QCloudGetBucketRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";// prevPageResult 是上一页的返回结果// 分页参数 默认以UTF-8二进制顺序列出条目,所有列出条目从marker开始request.marker = prevPageResult.nextMarker;// 单次返回的最大条目数量,默认1000request.maxKeys = 100;[request setFinishBlock:^(QCloudListBucketResult * result, NSError* error) {// result 返回具体信息// QCloudListBucketResult.contents 桶内文件数组// QCloudListBucketResult.commonPrefixes 桶内文件夹数组if (result.isTruncated) {// 表示数据被截断,需要拉取下一页数据self->prevPageResult = result;}}];[[QCloudCOSXMLService defaultCOSXML] GetBucket:request];
let getBucketReq = QCloudGetBucketRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketgetBucketReq.bucket = "examplebucket-1250000000";// 分页参数 默认以UTF-8二进制顺序列出条目,所有列出条目从marker开始if let result = self.prevPageResult {getBucketReq.marker = result.marker}// 单次返回的最大条目数量,默认1000getBucketReq.maxKeys = 100;// 前缀匹配getBucketReq.prefix = "dir/";getBucketReq.setFinish { (result, error) inif let result = result {// 文件列表let contents = result.contentsif (result.isTruncated) {// 数据被截断,需要请求下一页数据self.prevPageResult = result;}} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucket(getBucketReq);
QCloudGetBucketRequest* request = [QCloudGetBucketRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";// 单次返回的最大条目数量,默认1000request.maxKeys = 100;// 前缀匹配,用来规定返回的文件前缀地址request.prefix = @"dir1/";// 定界符为一个符号,如果有 Prefix,则将 Prefix 到 delimiter 之间的相同路径归为一类,// 定义为 Common Prefix,然后列出所有 Common Prefix。如果没有 Prefix,则从路径起点开始// delimiter:路径分隔符 固定为 /request.delimiter = @"/";// prevPageResult 是上一页的返回结果// 分页参数 默认以UTF-8二进制顺序列出条目,所有列出条目从marker开始request.marker = prevPageResult.nextMarker;[request setFinishBlock:^(QCloudListBucketResult * result, NSError* error) {// result 返回具体信息// QCloudListBucketResult.contents 桶内文件数组// QCloudListBucketResult.commonPrefixes 桶内文件夹数组if (result.isTruncated) {// 表示数据被截断,需要拉取下一页数据self->prevPageResult = result;}}];[[QCloudCOSXMLService defaultCOSXML] GetBucket:request];
let getBucketReq = QCloudGetBucketRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketgetBucketReq.bucket = "examplebucket-1250000000";// 单次返回的最大条目数量,默认1000getBucketReq.maxKeys = 100;// 前缀匹配,用来规定返回的文件前缀地址getBucketReq.prefix = "dir/";// 定界符为一个符号,如果有 Prefix,则将 Prefix 到 delimiter 之间的相同路径归为一类,// 定义为 Common Prefix,然后列出所有 Common Prefix。如果没有 Prefix,则从路径起点开始// delimiter:路径分隔符 固定为 /getBucketReq.delimiter = "/";// 分页参数 默认以UTF-8二进制顺序列出条目,所有列出条目从marker开始if let result = self.prevPageResult {getBucketReq.marker = result.marker}getBucketReq.setFinish { (result, error) inif let result = result {// 文件列表let contents = result.contentsif (result.isTruncated) {// 数据被截断,需要请求下一页数据self.prevPageResult = result;}} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucket(getBucketReq);
QCloudListObjectVersionsRequest* listObjectVersionsRequest = [[QCloudListObjectVersionsRequest alloc] init];// 存储桶名称listObjectVersionsRequest.bucket = @"bucketname";// 一页请求数据条目数,默认 1000listObjectVersionsRequest.maxKeys = 100;//从当前key列出剩余的条目listObjectVersionsRequest.keyMarker = prevPageResult.nextKeyMarker;//从当前key的某个版本列出剩余的条目listObjectVersionsRequest.versionIdMarker = prevPageResult.nextVersionIDMarkder;[listObjectVersionsRequest setFinishBlock:^(QCloudListVersionsResult * _Nonnull result,NSError * _Nonnull error) {// 已删除的文件NSArray<QCloudDeleteMarker*> *deleteMarker = result.deleteMarker;// 对象版本条目NSArray<QCloudVersionContent*> *versionContent = result.versionContent;if (result.isTruncated) {// 表示数据被截断,需要拉取下一页数据self->prevPageResult = result;}}];[[QCloudCOSXMLService defaultCOSXML] ListObjectVersions:listObjectVersionsRequest];
本页内容是否解决了您的问题?