-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (41 loc) · 1.56 KB
/
Copy pathmain.cpp
File metadata and controls
55 lines (41 loc) · 1.56 KB
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
45
46
47
48
49
50
51
52
53
54
55
#include <aws/core/Aws.h>
#include <aws/core/utils/memory/stl/AWSAllocator.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/ListObjectsRequest.h>
#include <bolt_s3_client.h>
#include <bolt_s3_config.h>
#include <bolt_s3_http_client_factory.h>
#include <iostream>
using namespace Aws;
static const char ALLOCATION_TAG[] = "BoltS3HttpClientFactory";
std::shared_ptr<Aws::Http::HttpClientFactory> CreateFactory() { return Aws::MakeShared<ProjectN::Bolt::BoltS3HttpClientFactory>(ALLOCATION_TAG); }
void ListObjects() {
SDKOptions options;
options.httpOptions.httpClientFactory_create_fn = CreateFactory;
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
std::string bucketName = "sdk-test-rvh";
ProjectN::Bolt::BoltConfig::customDomain = "rvh.bolt.projectn.co";
InitAPI(options);
{
ProjectN::Bolt::BoltS3Client client;
// Aws::S3::S3Client client;
Aws::S3::Model::ListObjectsRequest request;
request.WithBucket(bucketName);
auto outcome = client.ListObjects(request);
if (!outcome.IsSuccess()) {
std::cerr << "Error: ListObjects: " << outcome.GetError().GetMessage() << std::endl;
} else {
Aws::Vector<Aws::S3::Model::Object> objects = outcome.GetResult().GetContents();
std::cout << "Objects in " << bucketName << ":" << std::endl;
for (Aws::S3::Model::Object &object : objects) {
std::cout << "\t- " << object.GetKey() << std::endl;
}
}
}
// Before the application terminates, the SDK must be shut down.
ShutdownAPI(options);
}
int main() {
ListObjects();
return 0;
}