API | 操作名 | 操作描述 |
查询对象列表 | 查询存储桶下的部分或者全部对象 | |
查询对象及其历史版本列表 | 查询存储桶下的部分或者全部对象及其历史版本信息 |
String bucketName = "examplebucket-1250000000"; //格式:BucketName-APPID;final GetBucketRequest getBucketRequest = new GetBucketRequest(bucketName);// 前缀匹配,用来规定返回的对象前缀地址getBucketRequest.setPrefix("dir/");// 单次返回最大的条目数量,默认1000getBucketRequest.setMaxKeys(100);cosXmlService.getBucketAsync(getBucketRequest, new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {GetBucketResult getBucketResult = (GetBucketResult) result;if (getBucketResult.listBucket.isTruncated) {// 表示数据被截断,需要拉取下一页数据prevPageResult = getBucketResult;}}// 如果您使用 kotlin 语言来调用,请注意回调方法中的异常是可空的,否则不会回调 onFail 方法,即:// clientException 的类型为 CosXmlClientException?,serviceException 的类型为 CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
String bucketName = "examplebucket-1250000000"; //格式:BucketName-APPID;GetBucketRequest getBucketRequest = new GetBucketRequest(bucketName);// 前缀匹配,用来规定返回的对象前缀地址getBucketRequest.setPrefix("dir/");// prevPageResult 是上一页的返回结果,这里的 nextMarker 表示下一页的起始位置String nextMarker = prevPageResult.listBucket.nextMarker;getBucketRequest.setMarker(nextMarker);// 单次返回最大的条目数量,默认1000getBucketRequest.setMaxKeys(100);cosXmlService.getBucketAsync(getBucketRequest, new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {GetBucketResult getBucketResult = (GetBucketResult) result;if (getBucketResult.listBucket.isTruncated) {// 表示数据被截断,需要拉取下一页数据}}// 如果您使用 kotlin 语言来调用,请注意回调方法中的异常是可空的,否则不会回调 onFail 方法,即:// clientException 的类型为 CosXmlClientException?,serviceException 的类型为 CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
String bucketName = "examplebucket-1250000000"; //格式:BucketName-APPID;GetBucketRequest getBucketRequest = new GetBucketRequest(bucketName);// 前缀匹配,用来规定返回的对象前缀地址getBucketRequest.setPrefix("dir/");// 单次返回最大的条目数量,默认1000getBucketRequest.setMaxKeys(100);// 定界符为一个符号,如果有 Prefix,// 则将 Prefix 到 delimiter 之间的相同路径归为一类,定义为 Common Prefix,// 然后列出所有 Common Prefix。如果没有 Prefix,则从路径起点开始getBucketRequest.setDelimiter("/");cosXmlService.getBucketAsync(getBucketRequest, new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {GetBucketResult getBucketResult = (GetBucketResult) result;}// 如果您使用 kotlin 语言来调用,请注意回调方法中的异常是可空的,否则不会回调 onFail 方法,即:// clientException 的类型为 CosXmlClientException?,serviceException 的类型为 CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
String bucketName = "examplebucket-1250000000"; //格式:BucketName-APPID;final GetBucketObjectVersionsRequest getBucketRequest =new GetBucketObjectVersionsRequest(bucketName);// 前缀匹配,用来规定返回的对象前缀地址getBucketRequest.setPrefix("dir/");// 单次返回最大的条目数量,默认1000getBucketRequest.setMaxKeys(100);cosXmlService.getBucketObjectVersionsAsync(getBucketRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {GetBucketObjectVersionsResult getBucketResult =(GetBucketObjectVersionsResult) result;if (getBucketResult.listVersionResult.isTruncated) {// 表示数据被截断,需要拉取下一页数据prevPageResult = getBucketResult;}}// 如果您使用 kotlin 语言来调用,请注意回调方法中的异常是可空的,否则不会回调 onFail 方法,即:// clientException 的类型为 CosXmlClientException?,serviceException 的类型为 CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
String bucketName = "examplebucket-1250000000"; //格式:BucketName-APPID;final GetBucketObjectVersionsRequest getBucketRequest =new GetBucketObjectVersionsRequest(bucketName);// 前缀匹配,用来规定返回的对象前缀地址getBucketRequest.setPrefix("dir/");// 单次返回最大的条目数量,默认1000getBucketRequest.setMaxKeys(100);// prevPageResult 是上一页的返回结果,这里的 nextMarker 与 nextVersionIdMarker// 表示下一页的起始位置getBucketRequest.setKeyMarker(prevPageResult.listVersionResult.nextKeyMarker);getBucketRequest.setVersionIdMarker(prevPageResult.listVersionResult.nextVersionIdMarker);cosXmlService.getBucketObjectVersionsAsync(getBucketRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {GetBucketObjectVersionsResult getBucketResult =(GetBucketObjectVersionsResult) result;if (getBucketResult.listVersionResult.isTruncated) {// 表示数据被截断,需要拉取下一页数据prevPageResult = getBucketResult;}}// 如果您使用 kotlin 语言来调用,请注意回调方法中的异常是可空的,否则不会回调 onFail 方法,即:// clientException 的类型为 CosXmlClientException?,serviceException 的类型为 CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
本页内容是否解决了您的问题?