PaperclipOpenURI::HTTPError(403 禁止)与 Amazon S3 存储

PaperclipOpenURI::HTTPError (403 Forbidden) with Amazon S3 Storage

我使用 Paperclip 将图像存储在 S3 中,但此错误时常出现。几周前我通过升级到 ruby 2.1.5 解决了这个问题,但现在又回来了。

这是我的控制器代码:

  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 & Ruby 2.1.5

我不得不将 expiring_url 扩展到 10000。