Allinea replay alla UI live e corregge miniature e loghi.
Player contenuto come la diretta, fix streaming thumbnail da S3, volume persistente ActiveStorage in produzione. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,6 +6,8 @@ module Recordings
|
||||
# Serve file replay/thumbnail al browser senza esporre URL S3 interni (es. http://garage:3900).
|
||||
class ServeFromStorage
|
||||
CHUNK_SIZE = 256 * 1024
|
||||
# Thumbnail e file piccoli: buffer completo (l'Enumerator su Puma può non completare la risposta).
|
||||
SMALL_FILE_MAX = 2 * 1024 * 1024
|
||||
|
||||
def initialize(key:, content_type:, disposition: "inline", filename: nil)
|
||||
@key = key
|
||||
@@ -55,6 +57,15 @@ module Recordings
|
||||
|
||||
controller.status = :partial_content if range.present? && resp.content_range.present?
|
||||
|
||||
if range.blank? && resp.content_length.to_i.positive? && resp.content_length.to_i <= SMALL_FILE_MAX
|
||||
return controller.send_data(
|
||||
resp.body.read,
|
||||
type: @content_type,
|
||||
disposition: @disposition,
|
||||
filename: @filename
|
||||
)
|
||||
end
|
||||
|
||||
body = resp.body
|
||||
controller.response_body = Enumerator.new do |yielder|
|
||||
while (chunk = body.read(CHUNK_SIZE))
|
||||
|
||||
Reference in New Issue
Block a user