FIX: file helper to download file using chunks of 512KB

This commit is contained in:
Régis Hanol 2015-05-19 12:39:46 +02:00
parent b25f223bfc
commit f0b35b2fe2
1 changed files with 2 additions and 2 deletions

View File

@ -15,11 +15,11 @@ class FileHelper
File.open(tmp.path, "wb") do |f|
downloaded = uri.open("rb", read_timeout: 5, redirect: follow_redirect)
while f.size <= max_file_size && data = downloaded.read(max_file_size)
while f.size <= max_file_size && data = downloaded.read(512.kilobytes)
f.write(data)
end
# tiny files are StringIO, no close! on them
downloaded.close! if downloaded.respond_to? :close!
downloaded.try(:close!) rescue nil
end
tmp