I’m using carrierwave and serve upload files via Cloudfront:
CarrierWave.configure do |config|
config.storage = :fog
config.asset_host = ENV['ASSET_HOST_URL'] # //d2qvudevhp5xne.cloudfront.net
end
post.photo.thumb.url # //d2qvudevhp5xne.cloudfront.net/uploads/posts/1/some_file_thumb.png
It works great for both http and https pages that render in browser, but in my app I also have JSON API endpoint ‘/v1/posts/1’ to response this post in JSON representation as well. And the consumer of this APIs are mobile app, so they don’t recognize this url to render the images.