带有 Amazon S3 存储的 PaperclipOpenURI::HTTPError (403 Forbidden) [英] PaperclipOpenURI::HTTPError (403 Forbidden) with Amazon S3 Storage

查看:72
本文介绍了带有 Amazon S3 存储的 PaperclipOpenURI::HTTPError (403 Forbidden)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Paperclip 将图像存储在 S3 中,并且此错误间歇性地出现.几周前我通过升级到 ruby​​ 2.1.5 解决了这个问题,但现在又回来了.

I have images stored in S3 with Paperclip and this error is intermittenly showing up. I had it resolved a few weeks ago by upgrading to ruby 2.1.5, but it's back now.

这是我的控制器代码:

  def download
    extension = File.extname(@gallery_photo.image_file_name)
    send_data open("#{@gallery_photo.image.expiring_url(10, :original)}").read, filename: "original_#{@gallery_photo.id}#{extension}", type: @gallery_photo.image_content_type
  end

错误如下:

OpenURI::HTTPError (403 Forbidden):

Rails 4 &红宝石 2.1.5

Rails 4 & Ruby 2.1.5

推荐答案

我不得不将 expiring_url 扩展到 10000.

I had to extend the expiring_url to 10000.

这篇关于带有 Amazon S3 存储的 PaperclipOpenURI::HTTPError (403 Forbidden)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆