Skip to content

Commit

Permalink
Document ActiveStorage::Preview#download
Browse files Browse the repository at this point in the history
  • Loading branch information
Dany Marcoux committed Jul 20, 2021
1 parent de8d345 commit 460a5ae
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions activestorage/app/models/active_storage/preview.rb
Expand Up @@ -75,6 +75,13 @@ def key
end
end

# Downloads the file associated with this preview's variant.
# Raises ActiveStorage::Preview::UnprocessedError if the preview has not been processed yet.
#
# Downloads the file associated with this variant. If no block is given, the
# entire file is read into memory and returned. That'll use a lot of RAM for
# very large files. If a block is given, then the download is streamed and
# yielded in chunks.
def download(&block)
if processed?
variant.download(&block)
Expand Down

0 comments on commit 460a5ae

Please sign in to comment.