-
Notifications
You must be signed in to change notification settings - Fork 88
Description
I am attempting to utilize Waffle.Storage.S3 with Linode object storage which presents an AWS S3 compatible API, and this can be accomplished with the following config snippet:
config :waffle,
storage: Waffle.Storage.S3,
bucket: "mybucket",
virtual_host: true
config :ex_aws,
json_codec: Jason,
region: "local"
config :ex_aws, :s3, %{
access_key_id: "********",
secret_access_key: "*******",
scheme: "https://",
host: "us-ord-1.linodeobjects.com",
port: 443,
region: "us-east-1",
bucket: "mybucket"
}
Linode uses the <bucket>.<region>.<endpoint host> format for their S3 URIs, so I need to use the virtual_host option so the bucket gets prepended to the URI. However, this results in incorrect URLs being generated, because Waffle.Storage.S3 is hardcoded to use the AWS endpoint URLs for virtual host url generation:
defp default_host(definition, file_and_scope) do
case virtual_host() do
true -> "https://#{s3_bucket(definition, file_and_scope)}.s3.amazonaws.com"
_ -> "https://s3.amazonaws.com/#{s3_bucket(definition, file_and_scope)}"
end
end
URLs get output in the following format:
https://mybucket.s3.amazonaws.com
I cannot use the asset_host setting, because that will no longer use the bucket name during URL generation, and would prevent me from being able to use multiple buckets in my application.
This is not exclusive to Linode, any S3-compatible storage provider will have this same problem, such as MinIO, or any S3-compatible storage appliance. All generated URLs will be incorrect.
In my mind, Waffle needs to either respect the host setting provided in the ex_aws config, or it needs to present a new configuration option to set the base URL to be used during URL generation.