-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws.cpp
44 lines (37 loc) · 1.18 KB
/
aws.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
42
43
44
#include <iostream>
#include <memory>
#include <aws/core/Aws.h>
#include <aws/core/auth/AWSCredentialsProvider.h>
#include <aws/s3/S3Client.h>
bool ListBuckets(const Aws::Client::ClientConfiguration &clientConfig) {
auto client = Aws::S3::S3Client(
Aws::Auth::AWSCredentials("minioadmin", "minioadmin"), clientConfig,
Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, false);
auto outcome = client.ListBuckets();
bool result = true;
if (!outcome.IsSuccess()) {
std::cerr << "Failed with error: " << outcome.GetError() << std::endl;
result = false;
} else {
std::cout << "Found " << outcome.GetResult().GetBuckets().size()
<< " buckets\n";
for (auto &&b : outcome.GetResult().GetBuckets()) {
std::cout << b.GetName() << std::endl;
}
}
return result;
}
int main() {
Aws::SDKOptions options;
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
InitAPI(options);
{
Aws::Client::ClientConfiguration config;
config.endpointOverride = "localhost:9000";
config.scheme = Aws::Http::Scheme::HTTP;
config.verifySSL = false;
ListBuckets(config);
}
ShutdownAPI(options);
return 0;
}