pub struct UploadTask { /* private fields */ }Expand description
Stateful helper that mirrors the Firebase Web SDK’s resumable upload behaviour.
A task is created via StorageReference::upload_bytes_resumable
and can then be polled chunk-by-chunk (upload_next) or allowed to run to completion (run_to_completion).
Small payloads are uploaded with a single multipart request, whereas larger blobs utilise the resumable REST API.
Implementations§
Source§impl UploadTask
impl UploadTask
Sourcepub fn total_bytes(&self) -> u64
pub fn total_bytes(&self) -> u64
Returns the total number of bytes that will be uploaded.
Sourcepub fn bytes_transferred(&self) -> u64
pub fn bytes_transferred(&self) -> u64
Returns the number of bytes that have been successfully uploaded so far.
Sourcepub fn state(&self) -> UploadTaskState
pub fn state(&self) -> UploadTaskState
Current task state.
Sourcepub fn last_error(&self) -> Option<&StorageError>
pub fn last_error(&self) -> Option<&StorageError>
Last error reported by the task, if any.
Sourcepub fn metadata(&self) -> Option<&ObjectMetadata>
pub fn metadata(&self) -> Option<&ObjectMetadata>
Resulting object metadata after a successful upload.
Sourcepub fn upload_session_url(&self) -> Option<&str>
pub fn upload_session_url(&self) -> Option<&str>
The resumable session URL, if one has been established.
Sourcepub fn upload_next_with_progress<F>(
&mut self,
progress: F,
) -> StorageResult<Option<ObjectMetadata>>where
F: FnMut(UploadProgress),
pub fn upload_next_with_progress<F>(
&mut self,
progress: F,
) -> StorageResult<Option<ObjectMetadata>>where
F: FnMut(UploadProgress),
Uploads the next chunk and invokes the provided progress callback.
Returns Ok(Some(metadata)) when the upload finishes and the remote metadata is available.
Sourcepub fn upload_next(&mut self) -> StorageResult<Option<ObjectMetadata>>
pub fn upload_next(&mut self) -> StorageResult<Option<ObjectMetadata>>
Uploads the next chunk without emitting progress callbacks.
Sourcepub fn run_to_completion_with_progress<F>(
self,
progress: F,
) -> StorageResult<ObjectMetadata>where
F: FnMut(UploadProgress),
pub fn run_to_completion_with_progress<F>(
self,
progress: F,
) -> StorageResult<ObjectMetadata>where
F: FnMut(UploadProgress),
Runs the task to completion while notifying progress for each chunk.
Sourcepub fn run_to_completion(self) -> StorageResult<ObjectMetadata>
pub fn run_to_completion(self) -> StorageResult<ObjectMetadata>
Runs the task to completion without progress callbacks.