API | 操作名 | 操作描述 |
设置清单任务 | 设置存储桶的清单任务 | |
查询清单任务 | 查询存储桶的清单任务 | |
删除清单任务 | 删除存储桶的清单任务 |
QCloudPutBucketInventoryRequest *putReq = [QCloudPutBucketInventoryRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketputReq.bucket= @"examplebucket-1250000000";// 清单任务的名称putReq.inventoryID = @"list1";// 用户在请求体中使用 XML 语言设置清单任务的具体配置信息。配置信息包括清单任务分析的对象,// 分析的频次,分析的维度,分析结果的格式及存储的位置等信息。QCloudInventoryConfiguration *config = [QCloudInventoryConfiguration new];// 清单的名称,与请求参数中的 id 对应config.identifier = @"list1";// 清单是否启用的标识:// 如果设置为 true,清单功能将生效// 如果设置为 false,将不生成任何清单config.isEnabled = @"True";// 描述存放清单结果的信息QCloudInventoryDestination *des = [QCloudInventoryDestination new];QCloudInventoryBucketDestination *btDes =[QCloudInventoryBucketDestination new];// 清单分析结果的文件形式,可选项为 CSV 格式btDes.cs = @"CSV";// 存储桶的所有者 IDbtDes.account = @"1278687956";// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketbtDes.bucket = @"qcs::cos:ap-guangzhou::examplebucket-1250000000";// 清单分析结果的前缀btDes.prefix = @"list1";// COS 托管密钥的加密方式QCloudInventoryEncryption *enc = [QCloudInventoryEncryption new];enc.ssecos = @"";// 为清单结果提供服务端加密的选项btDes.encryption = enc;// 清单结果导出后存放的存储桶信息des.bucketDestination = btDes;// 描述存放清单结果的信息config.destination = des;// 配置清单任务周期QCloudInventorySchedule *sc = [QCloudInventorySchedule new];// 清单任务周期,可选项为按日或者按周,枚举值:Daily、Weeklysc.frequency = @"Daily";config.schedule = sc;QCloudInventoryFilter *fileter = [QCloudInventoryFilter new];fileter.prefix = @"myPrefix";config.filter = fileter;config.includedObjectVersions = QCloudCOSIncludedObjectVersionsAll;QCloudInventoryOptionalFields *fields = [QCloudInventoryOptionalFields new];fields.field = @[ @"Size",@"LastModifiedDate",@"ETag",@"StorageClass",@"IsMultipartUploaded",@"ReplicationStatus"];// 设置清单结果中应包含的分析项目config.optionalFields = fields;putReq.inventoryConfiguration = config;[putReq setFinishBlock:^(id outputObject, NSError *error) {// 可以从 outputObject 中获取 response 中 etag 或者自定义头部等信息NSDictionary * result = (NSDictionary *)outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutBucketInventory:putReq];
let putReq = QCloudPutBucketInventoryRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketputReq.bucket = "examplebucket-1250000000";// 清单任务的名称putReq.inventoryID = "list1";// 用户在请求体中使用 XML 语言设置清单任务的具体配置信息。配置信息包括清单任务分析的对象,// 分析的频次,分析的维度,分析结果的格式及存储的位置等信息。let config = QCloudInventoryConfiguration.init();// 清单的名称,与请求参数中的 id 对应config.identifier = "list1";// 清单是否启用的标识:// 如果设置为 true,清单功能将生效// 如果设置为 false,将不生成任何清单config.isEnabled = "True";// 描述存放清单结果的信息let des = QCloudInventoryDestination.init();let btDes = QCloudInventoryBucketDestination.init();// 清单分析结果的文件形式,可选项为 CSV 格式btDes.cs = "CSV";// 存储桶的所有者 IDbtDes.account = "1278687956";// 清单分析结果的存储桶名btDes.bucket = "qcs::cos:ap-guangzhou::examplebucket-1250000000";// 清单分析结果的前缀btDes.prefix = "list1";// COS 托管密钥的加密方式let enc = QCloudInventoryEncryption.init();enc.ssecos = "";// 为清单结果提供服务端加密的选项btDes.encryption = enc;// 清单结果导出后存放的存储桶信息des.bucketDestination = btDes;// 描述存放清单结果的信息config.destination = des;// 配置清单任务周期let sc = QCloudInventorySchedule.init();// 清单任务周期,可选项为按日或者按周,枚举值:Daily、Weeklysc.frequency = "Daily";config.schedule = sc;let fileter = QCloudInventoryFilter.init();fileter.prefix = "myPrefix";config.filter = fileter;config.includedObjectVersions = .all;let fields = QCloudInventoryOptionalFields.init();fields.field = [ "Size","LastModifiedDate","ETag","StorageClass","IsMultipartUploaded","ReplicationStatus"];// 设置清单结果中应包含的分析项目config.optionalFields = fields;putReq.inventoryConfiguration = config;putReq.finishBlock = {(result,error) inif let result = result {// result 包含响应的 header 信息} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putBucketInventory(putReq);
错误码 | 描述 | 状态码 |
InvalidArgument | 不合法的参数值 | HTTP 400 Bad Request |
TooManyConfigurations | 清单数量已经达到1000条的上限 | HTTP 400 Bad Request |
AccessDenied | 未授权的访问。您可能不具备访问该存储桶的权限 | HTTP 403 Forbidden |
QCloudGetBucketInventoryRequest *getReq = [QCloudGetBucketInventoryRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketgetReq.bucket = @"examplebucket-1250000000";// 清单任务的名称getReq.inventoryID = @"list1";[getReq setFinishBlock:^(QCloudInventoryConfiguration * _Nonnull result,NSError * _Nonnull error) {// result 包含清单的信息}];[[QCloudCOSXMLService defaultCOSXML] GetBucketInventory:getReq];
let req = QCloudGetBucketInventoryRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";// 清单任务的名称req.inventoryID = "list1";req.setFinish {(result,error) inif let result = result {// 任务信息let enabled = result.isEnabled} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucketInventory(req);
QCloudDeleteBucketInventoryRequest *delReq = [QCloudDeleteBucketInventoryRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketdelReq.bucket = @"examplebucket-1250000000";// 清单任务的名称delReq.inventoryID = @"list1";[delReq setFinishBlock:^(id outputObject, NSError *error) {// 可以从 outputObject 中获取 response 中 etag 或者自定义头部等信息NSDictionary * result = (NSDictionary *)outputObject;}];[[QCloudCOSXMLService defaultCOSXML] DeleteBucketInventory:delReq];
let delReq = QCloudDeleteBucketInventoryRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketdelReq.bucket = "examplebucket-1250000000";// 清单任务的名称delReq.inventoryID = "list1";delReq.finishBlock = {(result,error) inif let result = result {// result 包含响应的 header 信息} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().deleteBucketInventory(delReq);
本页内容是否解决了您的问题?