API | 操作名 | 操作描述 |
设置清单任务 | 设置存储桶的清单任务 | |
查询清单任务 | 查询存储桶的清单任务 | |
删除清单任务 | 删除存储桶的清单任务 |
// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";PutBucketInventoryRequest putBucketInventoryRequest =new PutBucketInventoryRequest(bucket);putBucketInventoryRequest.setInventoryId("exampleInventoryId");// 是否在清单中包含对象版本:// 如果设置为 All,清单中将会包含所有对象版本,// 并在清单中增加VersionId,IsLatest,DeleteMarker 这几个字段// 如果设置为 Current,则清单中不包含对象版本信息putBucketInventoryRequest.setIncludedObjectVersions(InventoryConfiguration.IncludedObjectVersions.ALL);// 备份频率putBucketInventoryRequest.setScheduleFrequency(InventoryConfiguration.SCHEDULE_FREQUENCY_DAILY);// 备份路径putBucketInventoryRequest.setDestination("CSV", "1000000000","examplebucket-1250000000", "region", "dir/");cosXmlService.putBucketInventoryAsync(putBucketInventoryRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {PutBucketInventoryResult putBucketInventoryResult =(PutBucketInventoryResult) 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();}}});
错误码 | 描述 | 状态码 |
InvalidArgument | 不合法的参数值 | HTTP 400 Bad Request |
TooManyConfigurations | 清单数量已经达到1000条的上限 | HTTP 400 Bad Request |
AccessDenied | 未授权的访问。您可能不具备访问该存储桶的权限 | HTTP 403 Forbidden |
// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";GetBucketInventoryRequest getBucketInventoryRequest =new GetBucketInventoryRequest(bucket);getBucketInventoryRequest.setInventoryId("exampleInventoryId");cosXmlService.getBucketInventoryAsync(getBucketInventoryRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {GetBucketInventoryResult getBucketInventoryResult =(GetBucketInventoryResult) 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();}}});
// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";DeleteBucketInventoryRequest deleteBucketInventoryRequest =new DeleteBucketInventoryRequest(bucket);deleteBucketInventoryRequest.setInventoryId("exampleInventoryId");cosXmlService.deleteBucketInventoryAsync(deleteBucketInventoryRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {DeleteBucketInventoryResult deleteBucketInventoryResult =(DeleteBucketInventoryResult) result;}// 如果您使用 kotlin 语言来调用,请注意回调方法中的异常是可空的,否则不会回调 onFail 方法,即:// clientException 的类型为 CosXmlClientException?,serviceException 的类型为 CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {}});
本页内容是否解决了您的问题?