instance method
stream
Ruby on Rails 7.2.3
Since v6.0.6 PrivateSignature
stream(key)
Reads the file for the given key in chunks, yielding each to the block.
Parameters
-
keyreq
Source
# File activestorage/lib/active_storage/service/gcs_service.rb, line 177
def stream(key)
file = file_for(key, skip_lookup: false)
chunk_size = 5.megabytes
offset = 0
raise ActiveStorage::FileNotFoundError unless file.present?
while offset < file.size
yield file.download(range: offset..(offset + chunk_size - 1)).string
offset += chunk_size
end
end
Defined in activestorage/lib/active_storage/service/gcs_service.rb line 177
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveStorage::Service::GCSService