@@ -3,24 +3,28 @@ defmodule Transport.S3.AggregatesUploader do
33 Helpers to upload a file, computes its sha256, and update a "latest" file.
44 """
55
6- @ spec upload_aggregate! ( Path . t ( ) , String . t ( ) , String . t ( ) ) :: :ok
6+ @ spec upload_aggregate! ( Path . t ( ) , String . t ( ) , String . t ( ) , Keyword . t ( ) ) :: :ok
77 @ doc """
88 This method takes a local `file` and upload 4 different files to our S3 `aggregates` bucket (the bucket is expected to exist):
99 - the `remote_path` and `remote_latest_path` containing the data from `file`
1010 - two companions files with `.sha256sum` extension appended (SHA256 sum is computed on the fly)
1111
12+ `options` are forwarded to `Transport.S3.stream_to_s3!/4`. Useful options:
13+ - `timeout:` it applies to each part of the multipart upload (and not the whole file!). Defaults to 30s, but may be increased for large files.
14+ - `max_concurrency:` it applies to the number of concurrent parts uploaded. Defaults to 4.
15+
1216 Example
1317
1418 with_tmp_file(fn file ->
1519 File.write(file, "some relevant data")
1620 upload_aggregate!(file, "aggregate-20250127193035.csv", "aggregate-latest.csv")
1721 end)
1822 """
19- def upload_aggregate! ( file , remote_path , remote_latest_path ) do
23+ def upload_aggregate! ( file , remote_path , remote_latest_path , options \\ [ ] ) do
2024 with_tmp_file ( fn checksum_file ->
2125 sha256! ( file , checksum_file )
2226
23- upload_files! ( file , checksum_file , remote_path )
27+ upload_files! ( file , checksum_file , remote_path , options )
2428 |> update_latest_files! ( remote_latest_path )
2529 end )
2630 end
@@ -61,11 +65,11 @@ defmodule Transport.S3.AggregatesUploader do
6165 File . write! ( checksum_file , hash )
6266 end
6367
64- defp upload_files! ( file , checksum_file , remote_path ) do
68+ defp upload_files! ( file , checksum_file , remote_path , options ) do
6569 remote_checksum_path = checksum_filename ( remote_path )
6670
67- stream_upload! ( file , remote_path )
68- stream_upload! ( checksum_file , remote_checksum_path )
71+ stream_upload! ( file , remote_path , options )
72+ stream_upload! ( checksum_file , remote_checksum_path , options )
6973
7074 { remote_path , remote_checksum_path }
7175 end
@@ -83,8 +87,8 @@ defmodule Transport.S3.AggregatesUploader do
8387 "#{ base_filename } .sha256sum"
8488 end
8589
86- defp stream_upload! ( file , filename ) do
87- Transport.S3 . stream_to_s3! ( :aggregates , file , filename )
90+ defp stream_upload! ( file , filename , options ) do
91+ Transport.S3 . stream_to_s3! ( :aggregates , file , filename , options )
8892 end
8993
9094 defp copy! ( s3_path , filename ) do
0 commit comments