Ayrad
Ayrad

Reputation: 4056

images are not getting displayed from amazon S3

edit

when I follow the generated link it links to the following error:

The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

I have set my paperclip configuration in config/environments/staging.rb

  config.paperclip_defaults = {
    :storage => :s3,
    :s3_credentials => {
      :bucket => ENV['S3_BUCKET'],
      :access_key_id => ENV['S3_KEY'],
      :secret_access_key => ENV['S3_SECRET'],
      :path => "/image/:id/:filename",
      :url => ":s3_domain_url"
    }
  }

I have set my env variables for the heroku staging env:

$ heroku config:set S3_BUCKET=staging_bucket --remote staging
$ heroku config:set S3_KEY=XXXXX --remote staging
$ heroku config:set S3_SECRET=XXXXX --remote staging

Images seem to be uploaded correctly and I can see them in the console but I cannot display them in the web application. The url that is generated for an image is:

http://s3.amazonaws.com/myapp-staging/assets/attachments/000/000/004/small/IMG_0902.JPG?1368381995

It seems correct except for the part after ? I don't know what refers to.

Upvotes: 0

Views: 4300

Answers (2)

Song Keang
Song Keang

Reputation: 357

my endpoint was in singapore and I had to add the following:

:s3_host_name => "s3-ap-southeast-1.amazonaws.com"

Upvotes: 1

craig.kaminsky
craig.kaminsky

Reputation: 5598

Have you ensured that your buckets are publicly available?

I ask because the value of the message node shown when I open the above link is: The specified bucket does not exist

I recall running into similar issues ages ago and it turned out that I was uploading images to my S3 bucket(s) via Paperclip (as well as CarrierWave) but had never set my buckets to 'public'. The images/files would appear in my S3 console but no one could view them.

You may want to check your buckets permissions/public status in the S3 console. https://console.aws.amazon.com/s3

Upvotes: 0

Related Questions