1
votes

I am using CarrierWave with Fog for my Rails app to uploads my image to AWS S3 bucket. My config as follow:

 CarrierWave.configure do |config|
  config.fog_provider = 'fog/aws'                        # required
  config.fog_credentials = {
    :provider               => 'AWS',
    :aws_access_key_id      => 'KEY',
    :aws_secret_access_key  => 'SECRET',
    :region                 => 'us-west-2'
  }
  config.fog_directory  = 'bucket101'
  config.fog_public = true
  config.fog_attributes = { 'Cache-Control' => "max-age=#{365.day.to_i}"}
end

The upload is success, but I can't view the uploaded image on the browser. This is what I get.

enter image description here

Thanks!!

1

1 Answers

4
votes

Do you see the file uploaded in the S3 Console? What are the permissions?

config.fog_public = true should have enabled public read. Note: that config has to be set (and the initializer re-run) before you do your upload in order to have an effect.