FIX: allow HTTP <-> HTTPS redirections when downloading images

This commit is contained in:
Régis Hanol 2015-08-17 19:21:30 +02:00
parent 827ea641b0
commit a3e76dc193
3 changed files with 5 additions and 1 deletions

View File

@ -53,6 +53,8 @@ gem 'fast_xs'
gem 'fast_xor'
gem 'open_uri_redirections'
# while we sort out https://github.com/sdsykes/fastimage/pull/46
gem 'fastimage_discourse', require: 'fastimage'
gem 'aws-sdk', require: false

View File

@ -214,6 +214,7 @@ GEM
multi_json (~> 1.11)
mustache
nokogiri (~> 1.6.6)
open_uri_redirections (0.2.1)
openid-redis-store (0.0.2)
redis
ruby-openid
@ -443,6 +444,7 @@ DEPENDENCIES
omniauth-openid
omniauth-twitter
onebox
open_uri_redirections
openid-redis-store
pg
pry-nav

View File

@ -14,7 +14,7 @@ class FileHelper
tmp = Tempfile.new([tmp_file_name, extension])
File.open(tmp.path, "wb") do |f|
downloaded = uri.open("rb", read_timeout: 5, redirect: follow_redirect)
downloaded = uri.open("rb", read_timeout: 5, redirect: follow_redirect, allow_redirections: :all)
while f.size <= max_file_size && data = downloaded.read(512.kilobytes)
f.write(data)
end