Skip to content

Commit

Permalink
Merge pull request #972 from PRX/fix/media_cache_headers
Browse files Browse the repository at this point in the history
Add some missing cache headers on media
cavis authored Feb 16, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 5c4bebc + 04dbffa commit c3cf5ce
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/models/media_resource.rb
Original file line number Diff line number Diff line change
@@ -92,6 +92,10 @@ def waveform_path
"#{path}.json"
end

def waveform_file_name
"#{file_name}.json"
end

def generate_waveform?
false
end
14 changes: 12 additions & 2 deletions app/models/tasks/copy_media_task.rb
Original file line number Diff line number Diff line change
@@ -112,7 +112,12 @@ def porter_slice_task
Destination: {
Mode: "AWS/S3",
BucketName: ENV["FEEDER_STORAGE_BUCKET"],
ObjectKey: porter_escape(media_resource.path)
ObjectKey: porter_escape(media_resource.path),
ContentType: "REPLACE",
Parameters: {
CacheControl: "max-age=86400",
ContentDisposition: "attachment; filename=\"#{porter_escape(media_resource.file_name)}\""
}
},
FFmpeg: {
OutputFileOptions: output_opts.join(" ")
@@ -128,7 +133,12 @@ def porter_waveform_task
Destination: {
Mode: "AWS/S3",
BucketName: ENV["FEEDER_STORAGE_BUCKET"],
ObjectKey: porter_escape(media_resource.waveform_path)
ObjectKey: porter_escape(media_resource.waveform_path),
Parameters: {
CacheControl: "max-age=86400",
ContentDisposition: "attachment; filename=\"#{porter_escape(media_resource.waveform_file_name)}\"",
ContentType: "application/json"
}
},
WaveformPointBitDepth: 8
}
7 changes: 6 additions & 1 deletion app/models/tasks/fix_media_task.rb
Original file line number Diff line number Diff line change
@@ -19,7 +19,12 @@ def porter_tasks
Destination: {
Mode: "AWS/S3",
BucketName: ENV["FEEDER_STORAGE_BUCKET"],
ObjectKey: porter_escape(media_resource.path)
ObjectKey: porter_escape(media_resource.path),
ContentType: "REPLACE",
Parameters: {
CacheControl: "max-age=86400",
ContentDisposition: "attachment; filename=\"#{porter_escape(media_resource.file_name)}\""
}
},
FFmpeg: {
OutputFileOptions: "-acodec copy"

0 comments on commit c3cf5ce

Please sign in to comment.