简体   繁体   English

未通过与Amazon S3的安全连接呈现的图像

[英]Images not rendered with secure connection to Amazon S3

I am creating a PDF which contains images which are stored on Amazon S3. 我正在创建一个PDF,其中包含存储在Amazon S3上的图像。 My Rails application uses https, so also the URL to the S3 image is https, which is configured in production.rb : 我的Rails应用程序使用https,因此S3映像的URL是https,它在production.rb配置:

config.paperclip_defaults = {
  :storage => :s3,
  :s3_protocol => :https
}

The issue is that the S3 bucket has a security bucket policy that it only shows the image when it is coming from my web domain. 问题是S3存储桶有一个安全存储桶策略,它只显示来自我的网域的图像。 This works well when showing the image in the view, because the referer is then my web domain which is whitelisted. 这在视图中显示图像时效果很好,因为引用者是我的网络域,列入白名单。

The issue when creating the PDF is that wicked_pdf tries to retrieve the image, but S3 can't see it is coming from my web domain and returns a 403 Forbidden . 创建PDF时的问题是wicked_pdf尝试检索图像,但S3无法看到它来自我的Web域并返回403 Forbidden So what can I do to solve this? 那么我该怎么做才能解决这个问题呢?

Since you've tagged your question with wicked-pdf I assume that's what you're using. 既然你用wicked-pdf标记了你的问题,我认为你正在使用它。 It looks like this is a known problem with some versions of that gem. 看起来这是该gem的某些版本的已知问题 The linked question gives several options to solve it. 链接的问题提供了几种解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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