ark::aws::S3Client

Defined in header “ark/aws/s3client.hh”.


A wrapper around an S3 client. Allows you to upload/download files from a bucket.

Methods

  • S3Client(std::string bucket_name)
    Constructor. Initializes a new client against the specified bucket.

  • S3Client(std::string bucket_name, core::Url endpoint)
    Constructor. Initializes a new client against the given URL. This is typically used for testing only.

  • S3Client(std::string bucket_name, core::Url endpoint, const std::shared_ptr< Aws::Auth::AWSCredentialsProvider > & credentials_provider)
    Constructor. Initializes a new client along with credential provider. This is useful when you want to control exactly how the AWScredentials are obtained for the client.

  • S3Client(std::string bucket_name, const AwsTemporaryCredentials & credentials)
    Constructor. Initializes a new client along with AWSCredentials. This is useful when you want to control exactly how the AWScredentials are obtained for the client.

  • S3Client(std::string bucket_name, core::Url endpoint, const AwsTemporaryCredentials & credentials)
    Constructor. Initializes a new client along with AWSCredentials. This is useful when you want to control exactly how the AWScredentials are obtained for the client.

  • void upload(const std::string & key_name, const std::string_view & data, const ObjectPolicy & policy)
    A helper function that will upload the contents of the given string view to the specified bucket and path.

  • void upload(const std::string & key_name, const std::vector< uint8_t > & data, const ObjectPolicy & policy)
    A helper function that will upload the contents of the given vector to the specified bucket and path.

  • void upload(const std::string & key_name, const std::filesystem::path & source, const ObjectPolicy & policy)
    A helper function that will upload the contents of the given path to the specified bucket and path.

  • void upload(const S3UploadRequest & request, const std::string_view & data)
    A helper function that will upload the contents of the given string view to the specified bucket and path.

  • void upload(const S3UploadRequest & request, const std::filesystem::path & source)
    A helper function that will upload the contents of the given path with settings from the request supplied.

  • bool exists(const std::string & key_name)
    Returns true if the given key name exists, or false otherwise.

  • std::optional< uint64_t > size(const std::string & key_name)
    Returns the size of the given key name if it exists, or an empty optional otherwise.

  • std::vector< std::string > list(const std::string & prefix)
    Returns a list of objects that match the given prefix.

  • core::ByteBuffer download(const std::string & key_name, size_t expected_size)
    A helper function which downloads the given key name, returning a byte buffer with the contents of the downloaded data.

    You can optionally fill in an expected size, which will preallocate the buffer to that size to potentially save memory copies during download.

  • void download_to_path(const std::string & key_name, const std::filesystem::path & output_path)
    Downloads the given key directly to the specified path, removing the need to download into memory.

  • void download_to_path(const std::string & key_name, const std::filesystem::path & output_path, S3ProgressCallback callback)
    Downloads the given key directly to the specified path, removing the need to download into memory. The given progress callback will be invoked periodically to let you know progress.

  • void remove(const std::string & key_name)
    Deletes the given key name from the S3 bucket.

  • core::Url generate_presigned_url(const std::string & key_name, comms::HttpRequestType request_type, std::chrono::seconds expiration_time, const std::map< std::string, std::string > & additional_headers)
    Generates a presigned URL for the given operation and key.

  • const std::string & bucket_name()
    Returns the name of the bucket this client is serving.

  • const core::Url & endpoint()
    Returns the endpoint this bucket connects to (if any).