pub struct UploadClient<'a, T: Transport, A: AuthProvider> { /* private fields */ }Expand description
Client for Nextcloud’s WebDAV Chunked Upload v2 protocol.
Manages creating upload directories, streaming individual chunks, assembling the uploaded chunks into the destination file, or aborting the upload.
Generic over the Transport and AuthProvider, held by reference so that
connection pools and credentials can be shared across tasks.
Implementations§
Source§impl<'a, T: Transport, A: AuthProvider> UploadClient<'a, T, A>
impl<'a, T: Transport, A: AuthProvider> UploadClient<'a, T, A>
Sourcepub const fn new(transport: &'a T, auth: &'a A) -> Self
pub const fn new(transport: &'a T, auth: &'a A) -> Self
Binds an upload client to a transport and credential provider.
Sourcepub async fn start(
&self,
user_id: &str,
destination_path: &str,
total_size: u64,
) -> Result<UploadSession, Error>
pub async fn start( &self, user_id: &str, destination_path: &str, total_size: u64, ) -> Result<UploadSession, Error>
Initializes a new chunked upload session by sending an MKCOL request with an auto-generated upload ID.
Sends MKCOL /remote.php/dav/uploads/{user_id}/{upload_id} with the Destination header set.
Sourcepub async fn start_with_id(
&self,
user_id: &str,
destination_path: &str,
total_size: u64,
upload_id: &str,
) -> Result<UploadSession, Error>
pub async fn start_with_id( &self, user_id: &str, destination_path: &str, total_size: u64, upload_id: &str, ) -> Result<UploadSession, Error>
Initializes a new chunked upload session using an explicit upload_id.
Sends MKCOL /remote.php/dav/uploads/{user_id}/{upload_id} with the Destination header set.
Sourcepub async fn upload_chunk(
&self,
session: &UploadSession,
chunk_index: u32,
chunk_data: Vec<u8>,
) -> Result<(), Error>
pub async fn upload_chunk( &self, session: &UploadSession, chunk_index: u32, chunk_data: Vec<u8>, ) -> Result<(), Error>
Uploads an individual chunk into the upload collection.
Sends PUT /remote.php/dav/uploads/{user_id}/{upload_id}/{chunk_number} with:
Destination: {destination_path}OC-Total-Length: {total_size}- payload containing
chunk_data
Automatically marks the chunk index as uploaded in the session upon success.
Sourcepub async fn finish(
&self,
session: &UploadSession,
mtime: Option<u64>,
) -> Result<(), Error>
pub async fn finish( &self, session: &UploadSession, mtime: Option<u64>, ) -> Result<(), Error>
Finalizes the upload by moving .file to the destination path.
Sends MOVE /remote.php/dav/uploads/{user_id}/{upload_id}/.file with:
Destination: {destination_path}OC-Total-Length: {total_size}- optionally
X-OC-Mtime: {mtime}