Class: ActiveStorage::Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/active_storage/downloader.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service) ⇒ Downloader

Returns a new instance of Downloader.



7
8
9
# File 'lib/active_storage/downloader.rb', line 7

def initialize(service)
  @service = service
end

Instance Attribute Details

#serviceObject (readonly)

Returns the value of attribute service.



5
6
7
# File 'lib/active_storage/downloader.rb', line 5

def service
  @service
end

Instance Method Details

#open(key, checksum:, name: "ActiveStorage-", tmpdir: nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/active_storage/downloader.rb', line 11

def open(key, checksum:, name: "ActiveStorage-", tmpdir: nil)
  open_tempfile(name, tmpdir) do |file|
    download key, file
    verify_integrity_of file, checksum: checksum
    yield file
  end
end