W3cubDocs

/Ruby on Rails 6.0

module ActiveStorage::Downloading

Public Class Methods

included(klass) Show source
# 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

Private Instance Methods

download_blob_to(file) Show source
# 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

Efficiently downloads blob data into the given file.

download_blob_to_tempfile() { |file| ... } Show source
# 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

Opens a new tempfile in tempdir and copies blob data into it. Yields the tempfile.

tempdir() Show source
# File activestorage/lib/active_storage/downloading.rb, line 43
def tempdir #:doc:
  Dir.tmpdir
end

Returns the directory in which tempfiles should be opened. Defaults to Dir.tmpdir.

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