14 #include <kvikio/defaults.hpp>
15 #include <kvikio/error.hpp>
16 #include <kvikio/utils.hpp>
77 virtual std::string
str()
const = 0;
120 std::string
str()
const override;
142 std::string _aws_sigv4;
143 std::string _aws_userpwd;
144 curl_slist* _curl_header_list{};
163 std::string object_name,
164 std::optional<std::string> aws_region,
165 std::optional<std::string> aws_endpoint_url);
175 [[nodiscard]]
static std::pair<std::string, std::string>
parse_s3_url(std::string
const& s3_url);
193 std::optional<std::string> aws_region = std::nullopt,
194 std::optional<std::string> aws_access_key = std::nullopt,
195 std::optional<std::string> aws_secret_access_key = std::nullopt,
196 std::optional<std::string> aws_session_token = std::nullopt);
215 S3Endpoint(std::pair<std::string, std::string> bucket_and_object_names,
216 std::optional<std::string> aws_region = std::nullopt,
217 std::optional<std::string> aws_access_key = std::nullopt,
218 std::optional<std::string> aws_secret_access_key = std::nullopt,
219 std::optional<std::string> aws_endpoint_url = std::nullopt,
220 std::optional<std::string> aws_session_token = std::nullopt);
224 std::string
str()
const override;
252 std::string
str()
const override;
280 std::string
str()
const override;
298 std::unique_ptr<RemoteEndpoint> _endpoint;
381 std::optional<std::vector<RemoteEndpointType>> allow_list = std::nullopt,
382 std::optional<std::size_t> nbytes = std::nullopt);
390 RemoteHandle(std::unique_ptr<RemoteEndpoint> endpoint, std::size_t nbytes);
422 [[nodiscard]] std::
size_t nbytes() const noexcept;
443 std::
size_t read(
void* buf, std::
size_t size, std::
size_t file_offset = 0);
457 std::future<std::
size_t> pread(
void* buf,
459 std::
size_t file_offset = 0,
460 std::
size_t task_size =
defaults::task_size());
Representation of a curl easy handle pointer and its operations.
A remote endpoint for HTTP/HTTPS resources.
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 for AWS S3 storage using presigned URLs.
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 for AWS S3 storage requiring credentials.
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.
A remote endpoint for publicly accessible S3 objects without authentication.
static bool is_url_valid(std::string const &url) noexcept
Whether the given URL is valid for S3 public endpoints.
std::size_t get_file_size() override
Get the size of the remote file.
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.
void setopt(CurlHandle &curl) override
Set needed connection options on a curl handle.
std::string str() const override
Get a description of this remote point instance.
Singleton class of default values used throughout KvikIO.
RemoteEndpointType
Types of remote file endpoints supported by KvikIO.