简体   繁体   中英

AWS S3 Images Uploaded to Rails via Paperclip Opening Locally, but not in Production (Heroku)

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.

我最终在存储和s3凭据之间的production.rb代码中发布了s3_host_name: 's3-us-west-1.amazonaws.com'行,从而解决了该问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM