class ActiveStorage::Service::S3Service
def stream(key)
def stream(key) object = object_for(key) chunk_size = 5.megabytes offset = 0 raise ActiveStorage::FileNotFoundError unless object.exists? while offset < object.content_length yield object.get(range: "bytes=#{offset}-#{offset + chunk_size - 1}").body.string.force_encoding(Encoding::BINARY) offset += chunk_size end end