I have a problem with carrierwave+fog+s3 using Amazon cloud front . In the following setup, I can upload files to s3, but after downloading the URLs of the S3 objects that I get from my rails application do not have the assets_host , that is, I set the URLs to look like this https://mycloudfrontname.cloudfront.net/uploads/myfile.mp3 format https://mycloudfrontname.cloudfront.net/uploads/myfile.mp3
But they are all displayed in this format https://mybucketname.s3.amazonaws.com/uploads/myfile.mp3
What could be wrong here?
CarrierWave.configure do |config| config.fog_credentials = { :provider => 'AWS', :aws_access_key_id => 'XXXX', :aws_secret_access_key => 'XXXX', :region => 'us-east-1' } config.fog_directory = 'mybucketname' config.asset_host = 'https://mycloudfrontname.cloudfront.net' config.fog_public = false config.fog_attributes = {'Cache-Control' => 'max-age=315576000'} end
UPDATE:
I found this bit of code from Carrierwave /lib/carrierwave/storage/fog.rb - So, if we set asset_host , as in the code snippet above, should this work correctly? or is there any other configuration i have to do?
def public_url if host = @uploader.asset_host if host.respond_to? :call "#{host.call(self)}/#{path}" else "#{host}/#{path}" end else
source share