2

I'm trying to get carrierwave to work with Amazon S3 (in my Rails 4 app), I use fog gem to upload the images to s3.

I'm currently successfully able to upload the files to my bucket. But I cannot get the images back. server is giving 403 (Forbidden) error

However if I check the image, it's there uploaded in S3. My image path would be something like

https://<bucket name>.s3.amazonaws.com/uploads/image/picture/8/card_34676_l.jpg&Signature=<signature>&Expires=<expires>

Following is my carrierwave config

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS',
    :aws_access_key_id      => '<key>',
    :aws_secret_access_key  => '<access key>',
  }
  config.fog_directory  = '<bucket name>' 
  config.fog_public     = false  
  config.fog_attributes = {'Cache-Control'=>"max-age=#{365.day.to_i}"} # optional, defaults to {}
end

and I have setup the default grantee permission to everyone with

  • list
  • upload/delete
  • view permissions

and have a default CORS Configuration setup

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
        <AllowedHeader>Authorization</AllowedHeader>
    </CORSRule>
</CORSConfiguration>

What could be missing?

halfer
  • 19,824
  • 17
  • 99
  • 186
sameera207
  • 16,547
  • 19
  • 87
  • 152
  • Hey, sorry to hear you are having trouble. Just a couple questions to clarify. In what way are you trying to access them? ie via the url or by using the internal carrierwave functionality? If it is the url, how are you generating it? – geemus Nov 14 '14 at 14:25
  • Hey @geemus, thanks for the comment, actually it turns out to be a mistake from my side ;) My bucket didnt have a `bucket policy`, adding a policy with read access for the content fixed the issue. thanks again and keep up the good work on `fog` :) – sameera207 Nov 16 '14 at 22:22
  • Glad to hear you found the fix and thanks for taking time to update with the details! – geemus Nov 17 '14 at 23:01

0 Answers0