mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FIX: file helper to download file using chunks of 512KB
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user