Skip to content

Commit b37c951

Browse files
committed
upload manifest to s3
1 parent 8b2fc97 commit b37c951

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/ex_webrtc_recorder.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,14 @@ defmodule ExWebRTC.Recorder do
320320
end)
321321

322322
manifest_diff = to_manifest(state.track_data, track_ids)
323+
files_to_upload = Map.put(manifest_diff, "manifest_file", %{location: state.manifest_path})
323324

324325
case state.upload_handler do
325326
nil ->
326327
{manifest_diff, nil, state}
327328

328329
handler ->
329-
{ref, handler} = S3.UploadHandler.spawn_task(handler, manifest_diff)
330+
{ref, handler} = S3.UploadHandler.spawn_task(handler, files_to_upload)
330331

331332
{manifest_diff, ref, %{state | upload_handler: handler}}
332333
end

lib/ex_webrtc_recorder/s3/upload_handler.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ if Code.ensure_loaded?(ExAws.S3) do
4040
def spawn_task(
4141
%__MODULE__{bucket_name: bucket_name, s3_config_overrides: s3_config_overrides} =
4242
handler,
43-
manifest
43+
files_to_upload
4444
) do
4545
s3_paths =
46-
Map.new(manifest, fn {id, %{location: path}} ->
46+
Map.new(files_to_upload, fn {id, %{location: path}} ->
4747
s3_path = path |> Path.basename() |> then(&Path.join(handler.base_path, &1))
4848

4949
{id, s3_path}
5050
end)
5151

5252
download_manifest =
53-
Map.new(manifest, fn {id, object_data} ->
53+
Map.new(files_to_upload, fn {id, object_data} ->
5454
{:ok, location} = Recorder.S3.Utils.to_url(bucket_name, s3_paths[id])
5555

5656
{id, %{object_data | location: location}}
@@ -60,7 +60,7 @@ if Code.ensure_loaded?(ExAws.S3) do
6060
# but this may require a slight change of the current UploadHandler logic
6161
task =
6262
Task.Supervisor.async(ExWebRTC.Recorder.TaskSupervisor, fn ->
63-
upload(manifest, bucket_name, s3_paths, s3_config_overrides)
63+
upload(files_to_upload, bucket_name, s3_paths, s3_config_overrides)
6464
end)
6565

6666
{task.ref,
@@ -95,8 +95,8 @@ if Code.ensure_loaded?(ExAws.S3) do
9595
{result, manifest, %__MODULE__{handler | tasks: tasks}}
9696
end
9797

98-
defp upload(manifest, bucket_name, s3_paths, s3_config_overrides) do
99-
Map.new(manifest, fn {id, %{location: path}} ->
98+
defp upload(files_to_upload, bucket_name, s3_paths, s3_config_overrides) do
99+
Map.new(files_to_upload, fn {id, %{location: path}} ->
100100
%{^id => s3_path} = s3_paths
101101
Logger.debug("Uploading `#{path}` to bucket `#{bucket_name}`, path `#{s3_path}`")
102102

0 commit comments

Comments
 (0)