mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-03-14 00:50:14 -04:00
FIX: file helper to download file using chunks of 512KB
This commit is contained in:
parent
b25f223bfc
commit
f0b35b2fe2
1 changed files with 2 additions and 2 deletions
|
@ -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 a new issue