FIX: file helper to download file using chunks of 512KB
This commit is contained in:
parent
b25f223bfc
commit
f0b35b2fe2
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue