модуль ActiveStorage::Downloading
Закрытые методы экземпляра
# File activestorage/lib/active_storage/downloading.rb, line 27
def download_blob_to(file) #:doc:
file.binmode
blob.download { |chunk| file.write(chunk) }
file.flush
file.rewind
end Эффективно загружает данные blob в указанный файл.
# File activestorage/lib/active_storage/downloading.rb, line 9
def download_blob_to_tempfile #:doc:
open_tempfile_for_blob do |file|
download_blob_to file
yield file
end
end Открывает новый временный файл в tempdir и копирует данные blob в него. Возвращает временный файл.
# File activestorage/lib/active_storage/downloading.rb, line 35 def tempdir #:doc: Dir.tmpdir end
Возвращает каталог, в котором должны открываться временные файлы. По умолчанию Dir.tmpdir.
© 2004–2018 David Heinemeier Hansson
Licensed under the MIT License.