Gcamara14
Gcamara14

Reputation: 538

AWS S3 not showing images on heroku?

I built a rails app and set up s3 and paperclip together. So far, the images are being posted into my s3 account. But on the live app it's not actually showing the image and just showing the broken file icon.

Any ideas why this is happening? Is it a paperclip error? is it Heroku? Is it my controller?

Here's the live app: http://petaluma-marin.herokuapp.com/Nutrition-Recipes Here's my repo: https://github.com/Gcamara14/Recipe_app

Thanks!!

Upvotes: 0

Views: 1118

Answers (2)

Rockwell Rice
Rockwell Rice

Reputation: 3002

Your url to the images is wrong. The URL for your second image currently is this

http://s3.amazonaws.com/recipe-app-gio/recipes/images/000/000/009/medium/Screen_Shot_2017-05-30_at_1.19.49_PM.png?1496243164

What it needs to be is this

http://s3-us-west-1.amazonaws.com/recipe-app-gio/recipes/images/000/000/009/medium/Screen_Shot_2017-05-30_at_1.19.49_PM.png?1496243164

Notice instead of http://s3.aws... at the beginning you need http://s3-us-west-1.aws...

Whenever I have issues with S3 I find it is easiest to go to the bucket and look at the path and then inspect the image or asset and see if they match.

Upvotes: 2

jdgray
jdgray

Reputation: 1983

To give you a hint about what the issue might be, in your browser if you copy/paste the url for a photo you should see this message:

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

Take a look at your paperclip_defaults. You are missing the s3_host_name that would contain something like s3-us-west-1 (as mentioned in one of the prior answers).

Also looks like there is an issue already created in the paperclip repo that should help you out (here).

Upvotes: 1

Related Questions