简体   繁体   English

通过本地打开的回形针将AWS S3图像上载到Rails,但不在生产环境中打开(Heroku)

[英]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.

相关问题 Rails 4,Carrierwave-aws,图像在本地上传到Amazon s3,但不在生产中(Openshift) - Rails 4, Carrierwave-aws, images uploaded to Amazon s3 locally, but not in production (Openshift) 通过PaperClip上传到s3的图像未显示在我的rails应用中 - images uploaded to s3 via PaperClip not displaying in my rails app 带有AWS S3 +回形针的Rails“缺少必需的:桶选项” —图像上传在Heroku上有效,但在本地不起作用 - Rails “missing required :bucket option” w/ AWS S3 + Paperclip — image upload works on Heroku but not locally Rails 3和Paperclip-我可以在S3或本地存储图像吗? - Rails 3 & Paperclip - Can I store images both on S3 & locally? Ruby on Rails,Paperclip,亚马逊AWS S3和Heroku - Ruby on Rails, Paperclip, Amazon AWS S3 & Heroku Heroku上的Rails 4中的回形针NameError(未初始化的常量AWS :: S3 :: Errors) - Paperclip NameError (uninitialized constant AWS::S3::Errors) in Rails 4 on heroku AWS S3和Paperclip无法在生产中使用。 - AWS S3 and Paperclip not working in production. Rails Heroku服务器回形针Amazon S3 - AWS :: S3 :: Errors :: RequestTimeout - Rails Heroku server paperclip Amazon S3 - AWS::S3::Errors::RequestTimeout 回形针到亚马逊s3图像到heroku无法正常工作 - paperclip to amazon s3 images to heroku not working heroku回形针导轨4 s3无法正常工作 - heroku paperclip rails 4 s3 not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM