[−][src]Function s3_algo::s3_upload_files
pub async fn s3_upload_files<P, F, C, I, R>(
s3: C,
bucket: String,
files: I,
cfg: UploadConfig,
progress: P,
default_request: R
) -> Result<(), Error> where
C: S3 + Clone + Send + Sync + Unpin + 'static,
P: Fn(RequestReport) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
I: Iterator<Item = ObjectSource> + Send + 'static,
R: Fn() -> PutObjectRequest + Clone + Unpin + Sync + Send + 'static,
Upload multiple files to S3.
path_to_key
is a function that converts a file path to the key it should have in S3.
The provided strip_prefix
function should cover most use cases.
s3_upload_files
provides counting of uploaded files and bytes through the progress
closure:
For common use cases it is adviced to use files_recursive
as files
.
progress
will be called after the upload of each file, with some data about that upload.
The first usize
parameter is the number of this file in the upload, while RequestReport
holds more data such as size in bytes, and the duration of the upload. It is thus possible to
report progress both in amount of files, or amount of bytes, depending on what granularity is
desired.
progress
returns a generic F: Future
to support async operations like, for example, logging the
results to a file; this future will be run as part of the upload algorithm.
default_request
constructs the default request struct - only the fields bucket
, key
,
body
and content_length
are overwritten by the upload algorithm.