pub struct TransferBuilder<'a, E> { /* private fields */ }Expand description
Builds a streaming transfer. Obtained from Cx::upload / Cx::download;
finished with start, which subscribes and returns the key.
Implementations§
Source§impl<'a, E> TransferBuilder<'a, E>
impl<'a, E> TransferBuilder<'a, E>
Sourcepub fn method(self, m: impl Into<String>) -> Self
pub fn method(self, m: impl Into<String>) -> Self
Override the upload method (default PUT). No effect on download.
Sourcepub fn multipart(self, field: impl Into<String>) -> Self
pub fn multipart(self, field: impl Into<String>) -> Self
Send as multipart/form-data: the file becomes a part named field, emitted after
any text field()s. Flips the default method to POST (an explicit method() wins).
Upload-only.
Sourcepub fn field(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn field(self, name: impl Into<String>, value: impl Into<String>) -> Self
Add a text field to the multipart body (order preserved). No effect unless
multipart() was called; no effect on download.
Sourcepub fn filename(self, name: impl Into<String>) -> Self
pub fn filename(self, name: impl Into<String>) -> Self
Override the multipart file part’s filename= (default: inferred from the source).
Sourcepub fn file_content_type(self, ct: impl Into<String>) -> Self
pub fn file_content_type(self, ct: impl Into<String>) -> Self
Override the multipart file part’s Content-Type (default: application/octet-stream).
Honored on iOS and Android. On the web shell the browser derives the part’s
content type from the Blob’s own MIME type, so this override is native-only in v1.
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Add a request header (order preserved, repeats allowed).
Sourcepub fn bearer(self, token: impl AsRef<str>) -> Self
pub fn bearer(self, token: impl AsRef<str>) -> Self
Sugar for header("Authorization", format!("Bearer {token}")).
Sourcepub fn start(
self,
key: impl Into<String>,
on_event: impl Fn(TransferEvent) -> E + Send + 'static,
) -> String
pub fn start( self, key: impl Into<String>, on_event: impl Fn(TransferEvent) -> E + Send + 'static, ) -> String
Subscribe under key. on_event fires per progress tick and once at Done.
Returns key so the caller can cx.unsubscribe(key).