ClickHouse/dbms/src/IO/S3Common.h

58 lines
975 B
C++
Raw Normal View History

2019-11-05 07:54:13 +00:00
#pragma once
2019-12-06 14:37:21 +00:00
#include <Common/config.h>
#if USE_AWS_S3
2019-12-03 16:23:24 +00:00
#include <regex>
2019-11-05 07:54:13 +00:00
#include <Core/Types.h>
#include <Poco/Net/HTTPRequest.h>
2019-12-03 16:23:24 +00:00
#include <aws/s3/S3Client.h>
2019-12-06 14:37:21 +00:00
#include <boost/noncopyable.hpp>
#include <Poco/URI.h>
#include <aws/core/Aws.h>
2019-11-05 07:54:13 +00:00
2019-12-06 14:37:21 +00:00
namespace DB::S3
2019-11-05 07:54:13 +00:00
{
2019-12-06 14:48:56 +00:00
class ClientFactory
{
2019-12-06 14:37:21 +00:00
public:
ClientFactory();
2019-12-06 14:48:56 +00:00
2019-12-06 14:37:21 +00:00
~ClientFactory();
2019-12-06 14:48:56 +00:00
2019-12-06 14:37:21 +00:00
static ClientFactory & instance();
2019-12-06 14:48:56 +00:00
2019-12-06 14:37:21 +00:00
std::shared_ptr<Aws::S3::S3Client> create(const String & endpoint,
const String & access_key_id,
const String & secret_access_key);
2019-12-06 14:48:56 +00:00
2019-12-06 14:37:21 +00:00
private:
static Aws::SDKOptions aws_options;
2019-12-03 16:23:24 +00:00
};
2019-12-06 14:37:21 +00:00
/**
2019-12-06 14:54:20 +00:00
* Represents S3 URI.
*
2019-12-06 14:37:21 +00:00
* The following patterns are allowed:
* s3://bucket/key
* http(s)://endpoint/bucket/key
*/
2019-12-06 14:48:56 +00:00
struct URI
{
Poco::URI uri;
2019-12-06 14:37:21 +00:00
// Custom endpoint if URI scheme is not S3.
String endpoint;
String bucket;
String key;
2019-12-03 16:23:24 +00:00
explicit URI (Poco::URI & uri_);
2019-12-06 14:37:21 +00:00
};
2019-12-03 16:23:24 +00:00
}
2019-11-05 07:54:13 +00:00
#endif