0
votes

I have a bucket set up on AWS S3 so I can upload images via paperclip. It's working perfectly on my Localhost, but in production the images ARE being uploaded to the bucket, but are not showing up. I have it narrowed down to the link that's being generated. The one that is being generated by rails isn't the same as the link that I see when I actually find the photo in the AWS folder structure.

Generated Link: http://s3.amazonaws.com/ocrphotobucket/blogs/images/000/000/001/original/53600574_l.jpg?1493660602

Good Link: https://s3-us-west-1.amazonaws.com/ocrphotobucket/blogs/images/000/000/001/original/53600574_l.jpg

I have searched many similar SO posts (like this and this), but nothing has worked. Can anyone see where I'm going wrong?

I have this in my production.rb:

  # AWS
  config.paperclip_defaults = {
    storage: :s3,
    s3_credentials: {
      bucket: ENV.fetch('S3_BUCKET_NAME'),
      access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
      secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
      s3_region: ENV.fetch('AWS_REGION'),
    }
  }

And I assume all my credentials are correct in Heroku, as the images are being uploaded. Thoughts?

UPDATE I double checked that all my credentials were correct in Heroku (they are) and I renamed the bucket not to include underscores (links above changed accordingly, but not otherwise). The problem persists.

1
Don't assume that your creds are correct! Go into Heroku's settings tab for your app and look at the environment vars you've added to make sure they match.bkunzi01
@bkunzi01 I double checked in the Heroku settings and everything is correct.Liz

1 Answers

0
votes

I ended up posting the line s3_host_name: 's3-us-west-1.amazonaws.com' in my production.rb code, between storage and s3 credentials, which fixed the problem.