tencent cloud

对象存储

动态与公告
产品动态
产品公告
产品简介
产品概述
功能概览
应用场景
产品优势
基本概念
地域和访问域名
规格与限制
产品计费
计费概述
计费方式
计费项
免费额度
计费示例
查看和下载账单
欠费说明
常见问题
快速入门
控制台快速入门
COSBrowser 快速入门
用户指南
创建请求
存储桶
对象
数据管理
批量处理
全球加速
监控与告警
运维中心
数据处理
内容审核
智能工具箱
数据工作流
应用集成
工具指南
工具概览
环境安装与配置
COSBrowser 工具
COSCLI 工具
COSCMD 工具
COS Migration 工具
FTP Server 工具
Hadoop 工具
COSDistCp 工具
HDFS TO COS 工具
GooseFS-Lite 工具
在线辅助工具
自助诊断工具
实践教程
概览
访问控制与权限管理
性能优化
使用 AWS S3 SDK 访问 COS
数据容灾备份
域名管理实践
图片处理实践
COS 音视频播放器实践
工作流实践
数据直传
内容审核实践
数据安全
数据校验
大数据实践
COS 成本优化解决方案
在第三方应用中使用 COS
迁移指南
本地数据迁移至 COS
第三方云存储数据迁移至 COS
以 URL 作为源地址的数据迁移至 COS
COS 之间数据迁移
Hadoop 文件系统与 COS 之间的数据迁移
数据湖存储
云原生数据湖
元数据加速
数据加速器 GooseFS
数据处理
数据处理概述
图片处理
媒体处理
内容审核
文件处理
文档处理
故障处理
获取 RequestId 操作指引
通过外网上传文件至 COS 缓慢
访问 COS 时返回403错误码
资源访问异常
POST Object 常见异常
API 文档
简介
公共请求头部
公共响应头部
错误码
请求签名
操作列表
Service 接口
Bucket 接口
Object 接口
批量处理接口
数据处理接口
任务与工作流
内容审核接口
云查毒接口
SDK 文档
SDK 概览
准备工作
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
小程序 SDK
错误码
鸿蒙(Harmony) SDK
终端 SDK 质量优化
安全与合规
数据容灾
数据安全
访问管理
常见问题
热门问题
一般性问题
计费计量问题
域名合规问题
存储桶配置问题
域名和 CDN 问题
文件操作问题
日志监控问题
权限管理问题
数据处理问题
数据安全问题
预签名 URL 问题
SDK 类问题
工具类问题
API 类问题
服务协议
Service Level Agreement
隐私政策
数据处理和安全协议
联系我们
词汇表

清单

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2024-01-04 18:00:58

简介

本文档提供关于清单的 API 概览以及 SDK 示例代码。
API
操作名
操作描述
设置清单任务
设置存储桶的清单任务
查询清单任务
查询存储桶的清单任务
列出清单任务
列出存储桶的清单任务
删除清单任务
删除存储桶的清单任务

设置清单任务

功能说明

PUT Bucket inventory 用于在存储桶中创建清单任务。

方法原型

CosResult BucketOp::PutBucketInventory(const PutBucketInventoryReq& req, PutBucketInventoryResp* resp);

请求示例

qcloud_cos::CosConfig config("./config.json");
qcloud_cos::CosAPI cos(config);
std::string bucket_name = "examplebucket-1250000000";
qcloud_cos::PutBucketInventoryReq req(bucket_name);
qcloud_cos::PutBucketInventoryResp resp;

// 设置清单任务
req.SetId("list");

COSBucketDestination destination;
destination.SetFormat("CSV");
destination.SetAccountId("100010974959");

destination.SetBucket("qcs::cos:ap-guangzhou::loggtest-1234567890");
destination.SetPrefix("/");
destination.SetEncryption(true);

OptionalFields fields;
fields.SetIsSize(true);
fields.SetIsLastModified(true);
fields.SetIsStorageClass(true);
fields.SetIsMultipartUploaded(true);
fields.SetIsReplicationStatus(true);
fields.SetIsEtag(true);

Inventory inventory;
inventory.SetIsEnable(true);
inventory.SetIncludedObjectVersions("All");
inventory.SetFilter("/");
inventory.SetId(req.GetId());
inventory.SetFrequency("Daily");
inventory.SetCOSBucketDestination(destination);
inventory.SetOptionalFields(fields);

req.SetInventory(inventory);

qcloud_cos::CosResult result = cos.PutBucketInventory(req, &resp);
if (result.IsSucc()) {
// 请求成功
} else {
// 请求失败,可以调用 CosResult 的成员函数输出错误信息,如 requestID 等
}

参数说明

参数
参数描述
类型
是否必填
req
PutBucketInventory 操作的请求
PutBucketInventoryReq
resp
PutBucketInventory 操作的响应
PutBucketInventoryResp
PutBucketInventoryReq 提供以下成员函数:
// 设置清单规则
void SetInventory(Inventory& inventory);
该请求涉及到的类定义如下:

// 清单配置参数
class Inventory {
void SetId(const std::string& id) // 设置清单的名称
void SetIsEnable(bool is_enabled) // 清单是否启用
void SetIncludedObjectVersions(const std::string& included_objectversions) // 是否在清单中包含对象版本:
void SetFilter(const std::string& filter) // 筛选待分析对象(前缀)
void SetCOSBucketDestination(const COSBucketDestination& destination) // 设置清单结果导出后存放的存储桶信息
void SetOptionalFields(const OptionalFields& fields) // 设置清单结果中应包含的分析项目
void SetFrequency(const std::string& frequency) // 设置清单任务的周期,支持 Daily 和 Weekly
}

// 清单结果中应包含的分析项目
class OptionalFields {
void SetIsSize(const bool size); // 设置是否需要文件大小
void SetIsLastModified(const bool last_modified) // 设置是否需要文件修改时间
void SetIsStorageClass(const bool storage_class) // 设置是否需要存储类型
void SetIsMultipartUploaded(const bool ismultipart_uploaded) // 设置是否需要分块上传
void SetIsReplicationStatus(const bool replication_status) // 设置是否需要跨区域复制状态
}

// 清单结果导出后存放的存储桶信息
class COSBucketDestination {
public:
void SetFormat(const std::string& format) // 设置清单生成文件格式,目前支持 CSV 格式
void SetAccountId(const std::string& accountId) // 存储桶的所有者 ID
void SetBucket(const std::string& bucket) // 设置存储桶完整 ID
void SetPrefix(const std::string& prefix) // 设置清单分析结果的存储桶名
void SetEncryption(const bool encryption) // 设置清单结果是否加密

错误码说明

该请求可能会发生的一些常见的特殊错误如下:
错误码
描述
状态码
InvalidArgument
不合法的参数值
HTTP 400 Bad Request
TooManyConfigurations
清单数量已经达到1000条的上限
HTTP 400 Bad Request
AccessDenied
未授权的访问。您可能不具备访问该存储桶的权限
HTTP 403 Forbidden

查询清单任务

功能说明

GET Bucket inventory 用于查询存储桶中用户的清单任务信息。

方法原型

CosResult CosAPI::GetBucketInventory(const GetBucketInventoryReq& request, GetBucketInventoryResp* response) {

请求示例

qcloud_cos::CosConfig config("./config.json");
qcloud_cos::CosAPI cos(config);
std::string bucket_name = "examplebucket-1250000000";
qcloud_cos::GetBucketInventoryReq req(bucket_name);
qcloud_cos::GetBucketInventoryResp resp;

// 设置清单任务
req.SetId("list");

qcloud_cos::CosResult result = cos.GetBucketInventoryResp(req, &resp);
if (result.IsSucc()) {
// 请求成功,获取清单信息
//const Inventory inventory = resp.GetInventory();
//std::cout << "inventory isenabled:" << inventory.GetIsEnable() << std::endl;
//std::cout << "inventory IncludedObjectVersions:" << inventory.GetIncludedObjectVersions() << std::endl;
//std::cout << "inventory filter:" << inventory.GetFilter() << std::endl;
//std::cout << "inventory id:" << inventory.GetId() << std::endl;
//std::cout << "inventory Frequency:" << inventory.GetFrequency() << std::endl;

//std:: cout << "===================================" << std::endl;
//COSBucketDestination destination = inventory.GetCOSBucketDestination();
//std::cout << "destination Format:" << destination.GetFormat() << std::endl;
//std::cout << "destination AccountID:" << destination.GetAccountId() << std::endl;
//std::cout << "destination Bucket:" << destination.GetBucket() << std::endl;
//std::cout << "destination Encryption:" << destination.GetEncryption() << std::endl;

//std:: cout << "===================================" << std::endl;
//
//OptionalFields fields = inventory.GetOptionalFields();

//std::cout << "fields Size:" << fields.GetIsSize() << std::endl;
//std::cout << "fields LastModified:" << fields.GetIsLastModified() << std::endl;
//std::cout << "fields StorageClass:" << fields.GetIsStorageClass() << std::endl;
//std::cout << "fields Region:" << fields.GetIsMultipartUploaded() << std::endl;
//std::cout << "fields ReplicationStatus:" << fields.GetIsReplicationStatus() << std::endl;
//std::cout << "fields Tag:" << fields.GetIsETag() << std::endl;
} else {
// 请求失败,可以调用 CosResult 的成员函数输出错误信息,如 requestID 等
}

参数说明

参数
参数描述
类型
是否必填
req
GetBucketInventory 操作的请求
GetBucketInventoryReq
resp
GetBucketInventory 操作的响应
GetBucketInventoryResp
GetBucketInventoryResp 提供以下成员函数:
// 获取清单规则
const Inventory& GetInventory() const;

查询所有清单

功能说明

List Bucket Inventory Configurations 用于请求返回一个存储桶中的所有清单任务。

方法原型

CosResult CosAPI::ListBucketInventoryConfigurations(const ListBucketInventoryConfigurationsReq& request, ListBucketInventoryConfigurationsResp* response) {

请求示例

qcloud_cos::CosConfig config("./config.json");
qcloud_cos::CosAPI cos(config);
std::string bucket_name = "examplebucket-1250000000";
qcloud_cos::ListBucketInventoryConfigurationsReq req(bucket_name);
qcloud_cos::ListBucketInventoryConfigurationsResp resp;

qcloud_cos::CosResult result = cos.ListBucketInventoryConfigurations(req, &resp);
if (result.IsSucc()) {
// 请求成功,获取清单信息
// std::cout << "===================ListBucketInventoryConfigurations=====================" << std::endl;
//
// std::vector<Inventory> inventory_vec = resp.GetInventory();
//
// std::cout << resp.GetIsTruncated() << std::endl;
// std::cout << resp.GetContinuationToken() << std::endl;
// std::cout << resp.GetNextContinuationToken() << std::endl;
//
// std::vector<Inventory>::iterator itr = inventory_vec.begin();
// for(; itr != inventory_vec.end(); ++itr) {
//
// std:: cout << "==============Inventory=============================" << std::endl;
// std::cout << "inventory id:" << itr->GetId() << std::endl;
// std::cout << "inventory isenabled:" << itr->GetIsEnable() << std::endl;
// std::cout << "inventory IncludedObjectVersions:" << itr->GetIncludedObjectVersions() << std::endl;
// std::cout << "inventory filter:" << itr->GetFilter() << std::endl;
// std::cout << "inventory Frequency:" << itr->GetFrequency() << std::endl;
// std:: cout << "==============GetCOSBucketDestination==================" << std::endl;
// COSBucketDestination destination = itr->GetCOSBucketDestination();
// std::cout << "destination Format:" << destination.GetFormat() << std::endl;
// std::cout << "destination AccountID:" << destination.GetAccountId() << std::endl;
// std::cout << "destination Bucket:" << destination.GetBucket() << std::endl;
// std::cout << "destination Encryption:" << destination.GetEncryption() << std::endl;
//
// std:: cout << "===================OptionalFields======================" << std::endl;
// OptionalFields fields = itr->GetOptionalFields();
// std::cout << "fields Size:" << fields.GetIsSize() << std::endl;
// std::cout << "fields LastModified:" << fields.GetIsLastModified() << std::endl;
// std::cout << "fields StorageClass:" << fields.GetIsStorageClass() << std::endl;
// std::cout << "fields Region:" << fields.GetIsMultipartUploaded() << std::endl;
// std::cout << "fields ReplicationStatus:" << fields.GetIsReplicationStatus() << std::endl;
// std::cout << "fields Tag:" << fields.GetIsETag() << std::endl;
// }
// std::cout << "===============ListBucketInventoryConfigurations end================" << std::endl;
} else {
// 请求失败,可以调用 CosResult 的成员函数输出错误信息,如 requestID 等
}


参数说明

参数
参数描述
类型
是否必填
req
ListBucketInventoryConfigurations 操作的请求
ListBucketInventoryConfigurationsReq
resp
ListBucketInventoryConfigurations 操作的响应
ListBucketInventoryConfigurationsResp
ListBucketInventoryConfigurationsReq 提供以下成员函数:
// 当 COS 响应体中 IsTruncated 为 true,且 NextContinuationToken 节点中存在参数值时,您可以将这个参数作为 continuation-token 参数值,以获取下一页的清单任务信息。
void SetContinuationToken(const std::string continuation_token);

删除清单任务

功能说明

DELETE Bucket inventory 用于删除存储桶中指定的清单任务。

方法原型

CosResult CosAPI::DeleteBucketInventory(const DeleteBucketInventoryReq& request, DeleteBucketInventoryResp* response);

请求示例

qcloud_cos::CosConfig config("./config.json");
qcloud_cos::CosAPI cos(config);
std::string bucket_name = "examplebucket-1250000000";
qcloud_cos::DeleteBucketInventoryReq req(bucket_name);
qcloud_cos::DeleteBucketInventoryResp resp;

qcloud_cos::CosResult result = cos.DeleteBucketInventory(req, &resp);
if (result.IsSucc()) {
// 请求成功
} else {
// 请求失败,可以调用 CosResult 的成员函数输出错误信息,如 requestID 等

参数说明

参数
参数描述
类型
是否必填
req
DeletBucketInventory 操作的请求
DeletBucketInventoryReq
resp
DeletBucketInventory 操作的响应
DeletBucketInventoryResp
DeleteBucketInventoryReq 提供以下成员函数:
void SetId(const std::string id) // 设置要删除清单的 ID


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan