17 #ifndef ARCHIVE_S3ARCHIVE_H_
18 #define ARCHIVE_S3ARCHIVE_H_
26 #include <openssl/evp.h>
29 #include <aws/core/Aws.h>
30 #include <aws/s3/S3Client.h>
46 std::unique_lock<std::mutex> lck(awsapi_mtx);
47 if (0 == awsapi_count++) {
48 Aws::InitAPI(awsapi_options);
56 if (0 != (env = getenv(
"AWS_REGION"))) {
59 if (0 != (env = getenv(
"AWS_ACCESS_KEY_ID"))) {
62 if (0 != (env = getenv(
"AWS_SECRET_ACCESS_KEY"))) {
65 if (0 != (env = getenv(
"AWS_ENDPOINT"))) {
84 auto env_s3_temp_dir = getenv(
"TMPDIR");
85 s3_temp_dir = env_s3_temp_dir ? env_s3_temp_dir :
"/tmp";
90 for (
auto& thread : threads) {
91 if (thread.joinable()) {
95 std::unique_lock<std::mutex> lck(awsapi_mtx);
96 if (0 == --awsapi_count) {
97 Aws::ShutdownAPI(awsapi_options);
106 throw std::runtime_error(
"AWS S3 support not available");
111 const std::string
land(
const std::string& objkey,
112 std::exception_ptr& teptr,
113 const bool for_detection);
114 void vacuum(
const std::string& objkey);
116 const std::string
land(
const std::string& objkey,
117 std::exception_ptr& teptr,
118 const bool for_detection) {
119 throw std::runtime_error(
"AWS S3 support not available");
122 throw std::runtime_error(
"AWS S3 support not available");
124 #endif // HAVE_AWS_S3
129 static int awsapi_count;
130 static std::mutex awsapi_mtx;
131 static Aws::SDKOptions awsapi_options;
133 std::unique_ptr<Aws::S3::S3Client> s3_client;
134 std::vector<std::thread> threads;
135 #endif // HAVE_AWS_S3
157 :
S3Archive(url, s3_access_key, s3_secret_key, s3_region, s3_endpoint, plain_text) {
const std::string land(const std::string &objkey, std::exception_ptr &teptr, const bool for_detection)
std::string s3_access_key
std::map< const std::string, const std::string > file_paths
const std::vector< std::string > & get_objkeys()
S3Archive(const std::string &url, const std::string &s3_access_key, const std::string &s3_secret_key, const std::string &s3_region, const std::string &s3_endpoint, const bool plain_text)
void init_for_read() override
std::string s3_secret_key
S3Archive(const std::string &url, const bool plain_text)
std::vector< std::string > objkeys
S3ParquetArchive(const std::string &url, const std::string &s3_access_key, const std::string &s3_secret_key, const std::string &s3_region, const std::string &s3_endpoint, const bool plain_text)
void vacuum(const std::string &objkey)
size_t get_total_file_size() const