PhoenixImageTools.Storage.S3 (phoenix_image_tools v0.3.0)
View SourceAn S3 storage adapter for PhoenixImageTools.
This module provides functionality to upload images to an S3-compatible storage service.
Configuration
config :phoenix_image_tools, :storage,
adapter: PhoenixImageTools.Storage.S3,
bucket: "your-bucket-name",
region: "your-region"
# Configure ExAws
config :ex_aws,
access_key_id: [{:system, "AWS_ACCESS_KEY_ID"}, :instance_role],
secret_access_key: [{:system, "AWS_SECRET_ACCESS_KEY"}, :instance_role]
Summary
Functions
Builds a URL for an S3 object.
Uploads a complete set of image sizes to S3.
Takes a Plug.Upload struct and generates all configured image sizes, uploading them to S3 with appropriate metadata.
Returns a map with URLs for each size, including a "default" and "thumbnail" URL.
Examples
iex> MyApp.Storage.S3.upload_to_complete_set(upload)
%{
"320" => "https://bucket.s3.amazonaws.com/articles/xs_uuid.webp",
"768" => "https://bucket.s3.amazonaws.com/articles/sm_uuid.webp",
"1024" => "https://bucket.s3.amazonaws.com/articles/md_uuid.webp",
"1280" => "https://bucket.s3.amazonaws.com/articles/lg_uuid.webp",
"1536" => "https://bucket.s3.amazonaws.com/articles/xl_uuid.webp",
"default" => "https://bucket.s3.amazonaws.com/articles/xl_uuid.webp",
"thumbnail" => "https://bucket.s3.amazonaws.com/articles/xs_uuid.webp"
}