View Source Plausible.S3 (Plausible v0.0.1)
Helper functions for S3 exports/imports.
Summary
Functions
Returns a presigned URL to download the exported Zip archive from S3. The URL expires in 24 hours.
Chunks and uploads Zip archive to the provided S3 destination.
Returns the pre-configured S3 bucket for CSV exports.
Returns access_key_id
and secret_access_key
to be used by ClickHouse during imports from S3.
Presigns an upload for an imported file.
Returns the pre-configured S3 bucket for CSV imports.
Functions
@spec download_url(String.t(), Path.t()) :: :uri_string.uri_string()
Returns a presigned URL to download the exported Zip archive from S3. The URL expires in 24 hours.
In the current implementation the bucket always goes into the path component.
@spec export_upload_multipart(Enumerable.t(), String.t(), Path.t(), String.t()) :: :ok
Chunks and uploads Zip archive to the provided S3 destination.
In the current implementation the bucket always goes into the path component.
@spec exports_bucket() :: String.t()
Returns the pre-configured S3 bucket for CSV exports.
config :plausible, Plausible.S3,
exports_bucket: System.fetch_env!("S3_EXPORTS_BUCKET")
Example:
iex> exports_bucket()
"test-exports"
@spec import_clickhouse_credentials() :: %{ access_key_id: String.t(), secret_access_key: String.t() }
Returns access_key_id
and secret_access_key
to be used by ClickHouse during imports from S3.
Example:
iex> import_clickhouse_credentials()
%{access_key_id: "minioadmin", secret_access_key: "minioadmin"}
Presigns an upload for an imported file.
In the current implementation the bucket always goes into the path component.
Example:
iex> upload = import_presign_upload(_site_id = 123, _filename = "imported_browsers.csv")
iex> true = String.ends_with?(upload.s3_url, "/test-imports/123/imported_browsers.csv")
iex> true = String.contains?(upload.presigned_url, "/test-imports/123/imported_browsers.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&")
@spec imports_bucket() :: String.t()
Returns the pre-configured S3 bucket for CSV imports.
config :plausible, Plausible.S3,
imports_bucket: System.fetch_env!("S3_IMPORTS_BUCKET")
Example:
iex> imports_bucket()
"test-imports"