class ActiveStorage::Blob
def open(tmpdir: nil, &block)
The tempfile is automatically closed and unlinked after the given block is executed.
end
# ...
blob.open(tmpdir: "/path/to/tmp") do |file|
By default, the tempfile is created in Dir.tmpdir. Pass +tmpdir:+ to create it in a different directory:
The tempfile's name is prefixed with +ActiveStorage-+ and the blob's ID. Its extension matches that of the blob.
Downloads the blob to a tempfile on disk. Yields the tempfile.
def open(tmpdir: nil, &block) service.open( key, checksum: checksum, verify: !composed, name: [ "ActiveStorage-#{id}-", filename.extension_with_delimiter ], tmpdir: tmpdir, &block ) end