Brief Description
We have two environments:
- demo that uses
storage/file_system
- production that uses
storage/s3
And so, we have single code user.avatar_url
in both environments of our API that responds with different format of url.
Expected behavior
-
production S3:
https://s3.eu-central-1.amazonaws.com/example/thumbs/6819bbcb4681118e77961246dd197237.jpg
-
demo file system:
https://<demo-host>/uploads/thumbs/6819bbcb4681118e77961246dd197237.jpg
Actual behavior
-
production S3:
https://s3.eu-central-1.amazonaws.com/example/thumbs/6819bbcb4681118e77961246dd197237.jpg
-
demo file system:
/uploads/thumbs/6819bbcb4681118e77961246dd197237.jpg
There is also parameter that should help us but actually can broke the production because of S3 usage:
user.avatar_url(host: Rails.application.routes.default_url_options[:host])
and need to be passed in all places we are use avatar_url what is really looks sad…
Proposal
Need to add attr host
into Shrine::Storage::FileSystem
that will be used before prefix
and return full form of url if we need it.