модуль ActiveStorage::Streaming
Константы
- DEFAULT_BLOB_STREAMING_DISPOSITION
Приватные методы экземпляра
# File activestorage/app/controllers/concerns/active_storage/streaming.rb, line 55
def send_blob_stream(blob, disposition: nil) # :doc:
send_stream(
filename: blob.filename.sanitized,
disposition: blob.forced_disposition_for_serving || disposition || DEFAULT_BLOB_STREAMING_DISPOSITION,
type: blob.content_type_for_serving) do |stream|
blob.download do |chunk|
stream.write chunk
end
end
end Потоковое отображение объекта blob из хранилища непосредственно в ответ. Расположение можно контролировать, задавая disposition. Тип содержимого и имя файла устанавливаются непосредственно из blob.
© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.