[英]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. 我在AWS S3上设置了存储桶,因此可以通过回形针上传图像。 It's working perfectly on my Localhost, but in production the images ARE being uploaded to the bucket, but are not showing up.
它可以在我的Localhost上正常运行,但是在生产中,图像已上传到存储桶中,但没有显示。 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.
Rails生成的链接与我在AWS文件夹结构中实际找到照片时看到的链接不同。
Generated Link: http://s3.amazonaws.com/ocrphotobucket/blogs/images/000/000/001/original/53600574_l.jpg?1493660602 生成的链接: 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 良好链接: 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. 找遍了很多类似的帖子SO(像这个和这个),但没有奏效。 Can anyone see where I'm going wrong?
谁能看到我要去哪里错了?
I have this in my production.rb
: 我的
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. 我认为我的所有凭据在Heroku中都是正确的,因为正在上传图像。 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). 更新我再次检查了我所有的凭证在Heroku中(它们是正确的),并且我将存储桶重命名为不包含下划线(以上链接已相应更改,但没有其他更改)。 The problem persists.
问题仍然存在。
我最终在存储和s3凭据之间的production.rb
代码中发布了s3_host_name: 's3-us-west-1.amazonaws.com'
行,从而解决了该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.