PhoenixKit.Modules.Storage.Providers.S3 (phoenix_kit v2.52.2)

Copy Markdown View Source

AWS S3 storage provider.

Stores files in Amazon S3 buckets using the ExAWS library. Supports all S3-compatible services (like Backblaze B2, Cloudflare R2, Tigris).

Files under 5 MB are uploaded via put_object (single request). Files at or above 5 MB use multipart upload via ExAws.S3.upload/4 with streaming and concurrent chunk uploads.

Summary

Functions

A bucket's endpoint, parsed: %{scheme:, host:, port:}; nil when none is set (plain AWS); {:error, :invalid_endpoint} when one is set but cannot be used. The one place a bucket's endpoint is read, so the host requests go to and the host a public URL names cannot disagree. The parsing itself is PhoenixKit.Modules.Storage.Endpoint.parse/1, shared with the Integrations validator so a connection is checked against the host it will be used on.

Whether name is a bucket name an S3-protocol service accepts: 3 to 63 lowercase letters, digits, dots and hyphens, starting and ending with a letter or digit, no .., and not shaped like an IP address. Nothing that could change the host or path of a request.

Functions

endpoint(arg1)

@spec endpoint(map()) ::
  PhoenixKit.Modules.Storage.Endpoint.parsed()
  | nil
  | {:error, :invalid_endpoint}

A bucket's endpoint, parsed: %{scheme:, host:, port:}; nil when none is set (plain AWS); {:error, :invalid_endpoint} when one is set but cannot be used. The one place a bucket's endpoint is read, so the host requests go to and the host a public URL names cannot disagree. The parsing itself is PhoenixKit.Modules.Storage.Endpoint.parse/1, shared with the Integrations validator so a connection is checked against the host it will be used on.

valid_bucket_name?(name)

@spec valid_bucket_name?(term()) :: boolean()

Whether name is a bucket name an S3-protocol service accepts: 3 to 63 lowercase letters, digits, dots and hyphens, starting and ending with a letter or digit, no .., and not shaped like an IP address. Nothing that could change the host or path of a request.