@@ -40,27 +40,37 @@ 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- files_to_upload
43+ manifest
4444 ) do
4545 s3_paths =
46- Map . new ( files_to_upload , fn { id , % { location: path } } ->
46+ Map . new ( manifest , 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 ( files_to_upload , fn { id , object_data } ->
53+ Map . new ( manifest , fn { id , object_data } ->
5454 { :ok , location } = Recorder.S3.Utils . to_url ( bucket_name , s3_paths [ id ] )
5555
5656 { id , % { object_data | location: location } }
5757 end )
5858
59+ manifest_s3_path =
60+ Path . join ( handler . base_path , "manifest.json" )
61+
62+ Recorder.S3.Utils . upload_manifest (
63+ download_manifest ,
64+ bucket_name ,
65+ manifest_s3_path ,
66+ s3_config_overrides
67+ )
68+
5969 # FIXME: this links, ideally we should use `async_nolink` instead
6070 # but this may require a slight change of the current UploadHandler logic
6171 task =
6272 Task.Supervisor . async ( ExWebRTC.Recorder.TaskSupervisor , fn ->
63- upload ( files_to_upload , bucket_name , s3_paths , s3_config_overrides )
73+ upload ( manifest , bucket_name , s3_paths , s3_config_overrides )
6474 end )
6575
6676 { task . ref ,
@@ -95,8 +105,8 @@ if Code.ensure_loaded?(ExAws.S3) do
95105 { result , manifest , % __MODULE__ { handler | tasks: tasks } }
96106 end
97107
98- defp upload ( files_to_upload , bucket_name , s3_paths , s3_config_overrides ) do
99- Map . new ( files_to_upload , fn { id , % { location: path } } ->
108+ defp upload ( manifest , bucket_name , s3_paths , s3_config_overrides ) do
109+ Map . new ( manifest , fn { id , % { location: path } } ->
100110 % { ^ id => s3_path } = s3_paths
101111 Logger . debug ( "Uploading `#{ path } ` to bucket `#{ bucket_name } `, path `#{ s3_path } `" )
102112
0 commit comments