Skip to content

Commit 04eb312

Browse files
committed
upload manifest with correct s3 paths
1 parent b37c951 commit 04eb312

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

lib/ex_webrtc_recorder/s3/upload_handler.ex

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,7 @@ if Code.ensure_loaded?(ExAws.S3) do
4949
{id, s3_path}
5050
end)
5151

52-
download_manifest =
53-
Map.new(files_to_upload, fn {id, object_data} ->
54-
{:ok, location} = Recorder.S3.Utils.to_url(bucket_name, s3_paths[id])
55-
56-
{id, %{object_data | location: location}}
57-
end)
58-
52+
download_manifest = prepare_download_manifest(files_to_upload, bucket_name, s3_paths)
5953
# FIXME: this links, ideally we should use `async_nolink` instead
6054
# but this may require a slight change of the current UploadHandler logic
6155
task =
@@ -118,6 +112,23 @@ if Code.ensure_loaded?(ExAws.S3) do
118112
{id, result}
119113
end)
120114
end
115+
116+
defp prepare_download_manifest(files_to_upload, bucket_name, s3_paths) do
117+
{manifest_file, track_files} = Map.pop(files_to_upload, "manifest_file")
118+
119+
download_manifest =
120+
Map.new(track_files, fn {id, object_data} ->
121+
{:ok, location} = Recorder.S3.Utils.to_url(bucket_name, s3_paths[id])
122+
{id, %{object_data | location: location}}
123+
end)
124+
125+
# Update the local manifest file to contain S3 URLs instead of local paths
126+
if manifest_file do
127+
:ok = File.write!(manifest_file.location, Jason.encode!(download_manifest))
128+
end
129+
130+
download_manifest
131+
end
121132
end
122133
else
123134
defmodule ExWebRTC.Recorder.S3.UploadHandler do

0 commit comments

Comments
 (0)