#include "s3api_client.hpp"
#include <userver/components/component_config.hpp>
namespace samples {
S3ApiSampleComponent::S3ApiSampleComponent(
)
: LoggableComponentBase(config, context),
auto my_client = GetClient();
DoVeryImportantThingsInS3(std::move(my_client));
}
s3api::ClientPtr S3ApiSampleComponent::GetClient() {
std::chrono::milliseconds{100},
2,
std::nullopt
);
http_client_, s3api::S3ConnectionType::kHttps, "s3-some-site.awsornot.com", connection_cfg
);
auto auth = std::make_shared<s3api::authenticators::AccessKey>("my-access-key", s3api::Secret("my-secret-key"));
return s3api::GetS3Client(std::move(s3_connection), std::move(auth), "mybucket");
}
void DoVeryImportantThingsInS3(s3api::ClientPtr client) {
std::string path = "path/to/object";
std::string data{"some string data"};
client->PutObject(path, std::move(data));
client->GetObject(path);
}
}