25 #include <kvikio/defaults.hpp>
26 #include <kvikio/error.hpp>
27 #include <kvikio/parallel_operation.hpp>
28 #include <kvikio/posix_io.hpp>
29 #include <kvikio/utils.hpp>
87 virtual std::string
str()
const = 0;
127 std::string
str()
const override;
146 std::string _aws_sigv4;
147 std::string _aws_userpwd;
148 curl_slist* _curl_header_list{};
163 static std::string unwrap_or_default(std::optional<std::string> aws_arg,
164 std::string
const& env_var,
165 std::string
const& err_msg =
"");
184 std::string object_name,
185 std::optional<std::string> aws_region,
186 std::optional<std::string> aws_endpoint_url);
196 [[nodiscard]]
static std::pair<std::string, std::string>
parse_s3_url(std::string
const& s3_url);
214 std::optional<std::string> aws_region = std::nullopt,
215 std::optional<std::string> aws_access_key = std::nullopt,
216 std::optional<std::string> aws_secret_access_key = std::nullopt,
217 std::optional<std::string> aws_session_token = std::nullopt);
236 S3Endpoint(std::pair<std::string, std::string> bucket_and_object_names,
237 std::optional<std::string> aws_region = std::nullopt,
238 std::optional<std::string> aws_access_key = std::nullopt,
239 std::optional<std::string> aws_secret_access_key = std::nullopt,
240 std::optional<std::string> aws_endpoint_url = std::nullopt,
241 std::optional<std::string> aws_session_token = std::nullopt);
245 std::string
str()
const override;
271 std::string
str()
const override;
289 std::unique_ptr<RemoteEndpoint> _endpoint;
372 std::optional<std::vector<RemoteEndpointType>> allow_list = std::nullopt,
373 std::optional<std::size_t> nbytes = std::nullopt);
381 RemoteHandle(std::unique_ptr<RemoteEndpoint> endpoint, std::size_t nbytes);
413 [[nodiscard]] std::
size_t nbytes() const noexcept;
434 std::
size_t read(
void* buf, std::
size_t size, std::
size_t file_offset = 0);
448 std::future<std::
size_t> pread(
void* buf,
450 std::
size_t file_offset = 0,
451 std::
size_t task_size =
defaults::task_size());
Representation of a curl easy handle pointer and its operations.
A remote endpoint using http.
void setup_range_request(CurlHandle &curl, std::size_t file_offset, std::size_t size) override
Set up the range request in order to read part of a file given the file offset and read size.
std::size_t get_file_size() override
Get the size of the remote file.
std::string str() const override
Get a description of this remote point instance.
HttpEndpoint(std::string url)
Create an http endpoint from a url.
void setopt(CurlHandle &curl) override
Set needed connection options on a curl handle.
static bool is_url_valid(std::string const &url) noexcept
Whether the given URL is valid for HTTP/HTTPS endpoints.
Abstract base class for remote endpoints.
RemoteEndpointType remote_endpoint_type() const noexcept
Get the type of the remote file.
virtual std::size_t get_file_size()=0
Get the size of the remote file.
virtual void setup_range_request(CurlHandle &curl, std::size_t file_offset, std::size_t size)=0
Set up the range request in order to read part of a file given the file offset and read size.
virtual void setopt(CurlHandle &curl)=0
Set needed connection options on a curl handle.
virtual std::string str() const =0
Get a description of this remote point instance.
RemoteEndpointType remote_endpoint_type() const noexcept
Get the type of the remote file.
static RemoteHandle open(std::string url, RemoteEndpointType remote_endpoint_type=RemoteEndpointType::AUTO, std::optional< std::vector< RemoteEndpointType >> allow_list=std::nullopt, std::optional< std::size_t > nbytes=std::nullopt)
Create a remote file handle from a URL.
RemoteHandle(std::unique_ptr< RemoteEndpoint > endpoint)
Create a new remote handle from an endpoint (infers the file size).
RemoteHandle(std::unique_ptr< RemoteEndpoint > endpoint, std::size_t nbytes)
Create a new remote handle from an endpoint and a file size.
A remote endpoint using AWS's S3 protocol and expecting a presigned URL. File access via this type of...
std::size_t get_file_size() override
Get the size of the remote file.
std::string str() const override
Get a description of this remote point instance.
void setup_range_request(CurlHandle &curl, std::size_t file_offset, std::size_t size) override
Set up the range request in order to read part of a file given the file offset and read size.
static bool is_url_valid(std::string const &url) noexcept
Whether the given URL is valid for S3 endpoints with presigned URL.
void setopt(CurlHandle &curl) override
Set needed connection options on a curl handle.
A remote endpoint using AWS's S3 protocol.
static std::string url_from_bucket_and_object(std::string bucket_name, std::string object_name, std::optional< std::string > aws_region, std::optional< std::string > aws_endpoint_url)
Get url from a AWS S3 bucket and object name.
static bool is_url_valid(std::string const &url) noexcept
Whether the given URL is valid for S3 endpoints (excluding presigned URL).
S3Endpoint(std::pair< std::string, std::string > bucket_and_object_names, std::optional< std::string > aws_region=std::nullopt, std::optional< std::string > aws_access_key=std::nullopt, std::optional< std::string > aws_secret_access_key=std::nullopt, std::optional< std::string > aws_endpoint_url=std::nullopt, std::optional< std::string > aws_session_token=std::nullopt)
Create a S3 endpoint from a bucket and object name.
S3Endpoint(std::string url, std::optional< std::string > aws_region=std::nullopt, std::optional< std::string > aws_access_key=std::nullopt, std::optional< std::string > aws_secret_access_key=std::nullopt, std::optional< std::string > aws_session_token=std::nullopt)
Create a S3 endpoint from a url.
void setopt(CurlHandle &curl) override
Set needed connection options on a curl handle.
void setup_range_request(CurlHandle &curl, std::size_t file_offset, std::size_t size) override
Set up the range request in order to read part of a file given the file offset and read size.
static std::pair< std::string, std::string > parse_s3_url(std::string const &s3_url)
Given an url like "s3://<bucket>/<object>", return the name of the bucket and object.
std::string str() const override
Get a description of this remote point instance.
std::size_t get_file_size() override
Get the size of the remote file.
Singleton class of default values used throughout KvikIO.
RemoteEndpointType
Types of remote file endpoints supported by KvikIO.