列举指定marker之后的文件
列举指定marker之后的文件(Object),默认列举1000个文件,最多列举1000个文件。代码中需要引用"inspurcloud/oss/OssClient.h"类库,使用InspurCloud::OSS命名空间,并初始化账号信息AccessKeyId、AccessKeySecret、Endpoint,示例代码:
//指定需要列举文件的存储桶及指定的marker
std::string BucketName = "yourBucketName";
std::string YourMarker = "yourMarker";
//列举指定marker之后的文件
request.setMarker(YourMarker);
auto outcome = client.ListObjects(request);
//处理结果
if (outcome.isSuccess()) {
for (const auto& object : outcome.result().ObjectSummarys()) {
std::cout << "object,name:" << object.Key() << ",size:" << object.Size() <<
",lastmodify time:" << object.LastModified() << std::endl;
}
}
//异常处理
else {
std::cout << "ListObjects fail" << std::endl;
std::cout << "error code:" << outcome.error().Code() << std::endl;
std::cout << "error message:" << outcome.error().Message() << std::endl;
std::cout << "requestId:" << outcome.error().RequestId() << std::endl;
}
//释放网络等资源
ShutdownSdk()