-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
41 lines (36 loc) · 1.12 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//snippet-start:[s3.cpp.list_buckets.inc]
#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/Bucket.h>
//snippet-end:[s3.cpp.list_buckets.inc]
/**
* List your Amazon S3 buckets.
*/
int main(int argc, char** argv)
{
Aws::SDKOptions options;
Aws::InitAPI(options);
{
// snippet-start:[s3.cpp.list_buckets.code]
Aws::S3::S3Client s3_client;
auto outcome = s3_client.ListBuckets();
if (outcome.IsSuccess())
{
std::cout << "Your Amazon S3 buckets:" << std::endl;
Aws::Vector<Aws::S3::Model::Bucket> bucket_list =
outcome.GetResult().GetBuckets();
for (auto const &bucket : bucket_list)
{
std::cout << " * " << bucket.GetName() << std::endl;
}
}
else
{
std::cout << "ListBuckets error: "
<< outcome.GetError().GetExceptionName() << " - "
<< outcome.GetError().GetMessage() << std::endl;
}
// snippet-end:[s3.cpp.list_buckets.code]
}
Aws::ShutdownAPI(options);
}