2015-04-01 79 views
0

我使用Paperclip将图像存储在S3中,并且此错误会间歇性地显示出来。几周前我通过升级到ruby 2.1.5解决了问题,但现在又回来了。PaperclipOpenURI :: HTTPError(403 Forbidden)with Amazon S3 Storage

这里是我的控制器代码:

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): 

轨道4 &的Ruby 2.1.5

+0

我有同样的问题,只为一些照片...任何想法? – 2015-06-11 07:40:36

回答

0

我不得不延长expiring_url为10000

+0

你能告诉我为什么你从10扩展到10000,我也希望我的链接在10秒内到期应该给什么 – user4965201 2015-11-17 09:23:37

+0

无论出于何种原因,我的设置需要超过10秒才能获取图像。这个应用程序偶尔可以在页面上加载500多张图片。否则,我相信我可以用更小的数字来获得。 – Preacher 2015-11-18 10:30:16