#[non_exhaustive]pub struct UploadRequest {
pub concurrency_per_file: usize,
pub dest_bucket: String,
pub dest_prefix: String,
pub sources: Vec<PathBuf>,
pub workers: usize,
/* private fields */
}Expand description
A batch upload request.
Accepts a list of files and/or directories. Directories are walked
recursively. All files are uploaded under dest_prefix in dest_bucket,
preserving relative paths from the common ancestor of sources.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.concurrency_per_file: usizeNumber of parts uploaded concurrently within a single multipart upload.
dest_bucket: StringTarget S3 bucket.
dest_prefix: StringKey prefix in the bucket (e.g. data/2024/).
sources: Vec<PathBuf>Local file or directory paths to upload.
workers: usizeNumber of files uploaded in parallel.
Implementations§
Source§impl UploadRequest
impl UploadRequest
Sourcepub fn file_count(&self) -> Result<usize>
pub fn file_count(&self) -> Result<usize>
Expand sources and count the total number of files that would be uploaded.
Useful for setting up progress bars before calling S3Client::upload.
§Errors
Returns an error if source expansion fails (e.g. non-UTF-8 paths).
Sourcepub fn new(
sources: Vec<PathBuf>,
dest_bucket: impl Into<String>,
dest_prefix: impl Into<String>,
) -> Self
pub fn new( sources: Vec<PathBuf>, dest_bucket: impl Into<String>, dest_prefix: impl Into<String>, ) -> Self
Create a new upload request with sensible defaults.
Defaults: 32 workers, 8 concurrent parts per file.
Each part is streamed from disk through a 256 KiB buffer, so peak
memory per file is roughly concurrency_per_file * 256 KiB.
Note: actual per-file concurrency is dynamically scaled based on each file’s size.
Sourcepub fn on_file_complete(
self,
callback: impl Fn(&FileUploadResult) + Send + Sync + 'static,
) -> Self
pub fn on_file_complete( self, callback: impl Fn(&FileUploadResult) + Send + Sync + 'static, ) -> Self
Set a callback that fires after each file upload completes.
The callback receives a reference to the FileUploadResult for the
just-completed file. It runs on the tokio worker thread, so keep it
lightweight (e.g. update a progress bar).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UploadRequest
impl !RefUnwindSafe for UploadRequest
impl Send for UploadRequest
impl Sync for UploadRequest
impl Unpin for UploadRequest
impl UnsafeUnpin for UploadRequest
impl !UnwindSafe for UploadRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more