class ActiveStorage::Service::GCSService

def stream(key)

Reads the file for the given key in chunks, yielding each to the block.
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