Spec-Zone.ru › Ruby on Rails 6.0

модуль ActiveStorage::Downloading

Публичные методы класса

included(klass) Показать исходный код
# File activestorage/lib/active_storage/downloading.rb, line 8
    def self.included(klass)
      ActiveSupport::Deprecation.warn <<~MESSAGE.squish, caller_locations(2)
        ActiveStorage::Downloading is deprecated and will be removed in Active Storage 6.1.
        Use ActiveStorage::Blob#open instead.
      MESSAGE
    end

Приватные методы экземпляра

download_blob_to(file) Показать исходный код
# File activestorage/lib/active_storage/downloading.rb, line 35
def download_blob_to(file) #:doc:
  file.binmode
  blob.download { |chunk| file.write(chunk) }
  file.flush
  file.rewind
end

Эффективно загружает данные blob в указанный файл.

download_blob_to_tempfile() { |file| ... } Показать исходный код
# File activestorage/lib/active_storage/downloading.rb, line 17
def download_blob_to_tempfile #:doc:
  open_tempfile_for_blob do |file|
    download_blob_to file
    yield file
  end
end

Открывает новый временный файл в tempdir и копирует данные blob в него. Возвращает временный файл.

tempdir() Показать исходный код
# File activestorage/lib/active_storage/downloading.rb, line 43
def tempdir #:doc:
  Dir.tmpdir
end

Возвращает директорию, в которой должны открываться временные файлы. По умолчанию Dir.tmpdir.

© 2004–2019 David Heinemeier Hansson
Licensed under the MIT License.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API