最近更新时间:2026-11-23 11:36:28
以下代码用于创建批量处理任务:
#include <ks3/ks3.h>
#include <iostream>
int main() {
ks3::KS3Client::Config cfg;
cfg.endpoint = "ks3-cn-beijing.ksyuncs.com";
ks3::KS3Client client("YOUR_AK", "YOUR_SK", cfg);
ks3::BatchJob job;
job.clientRequestToken = "token-001";
job.description = "batch restore archive objects";
job.priority = 10;
// 对象范围:目标桶 KRN 与前缀
ks3::BatchFilter f;
f.bucket = "krn:ksc:ks3:::src-bucket";
f.prefixes = {"prefix/"};
job.manifest.filters.push_back(f);
job.manifest.spec.format = ks3::BatchManifestFormat::BUCKET_V1;
// 完成报告
job.report.enabled = true;
job.report.bucket = "krn:ksc:ks3:::report-bucket";
job.report.prefix = "reports/";
job.report.reportScope = ks3::BatchReportScope::FAILED_TASKS_ONLY;
// 批量操作(六种互斥,置其一):此处以批量解冻为例
ks3::BatchKS3RestoreObject restore;
restore.storageClass = ks3::BatchStorageClass::ARCHIVE;
restore.days = 7;
restore.tier = ks3::BatchTier::EXPEDITED;
job.operation.ks3RestoreObject = restore;
// 批量删除:job.operation.ks3DeleteObject = true;
// 批量设置 ACL:设置 job.operation.ks3PutObjectAcl
// 批量冗余转换:设置 job.operation.ks3PutObjectDataRedundancyTransition
// 批量异步预热:job.operation.ks3AsyncWarmup = true;
// 批量压缩打包:设置 job.operation.ks3CompressObject
ks3::CreateJobRequest request;
request.SetConfiguration(job);
auto outcome = client.CreateJob(request);
if (outcome.IsSuccess()) {
std::cout << "JobId: " << outcome.result.jobId << std::endl;
} else {
std::cerr << "CreateJob failed: " << outcome.error.GetMessage() << std::endl;
}
return 0;
}
纯净模式
