Struct UploadSession

Source
pub struct UploadSession { /* private fields */ }
Expand description

An upload session for resumable file uploading process.

§See also

OneDrive::new_upload_session

Microsoft Docs

Implementations§

Source§

impl UploadSession

Source

pub const MAX_PART_SIZE: usize = 62_914_560usize

The upload size limit of a single upload_part call.

The value is from Microsoft Docs and may not be accurate or stable.

Source

pub fn from_upload_url(upload_url: impl Into<String>) -> Self

Construct back the upload session from upload URL.

Source

pub async fn get_meta(&self, client: &Client) -> Result<UploadSessionMeta>

Query the metadata of the upload to find out which byte ranges have been received previously.

§See also

Microsoft Docs

Source

pub fn upload_url(&self) -> &str

The URL endpoint accepting PUT requests.

It is exactly what you passed in UploadSession::from_upload_url.

Source

pub async fn delete(&self, client: &Client) -> Result<()>

Cancel the upload session

This cleans up the temporary file holding the data previously uploaded. This should be used in scenarios where the upload is aborted, for example, if the user cancels the transfer.

Temporary files and their accompanying upload session are automatically cleaned up after the expirationDateTime has passed. Temporary files may not be deleted immediately after the expiration time has elapsed.

§See also

Microsoft Docs

Source

pub async fn upload_part( &self, data: impl Into<Bytes>, remote_range: Range<u64>, file_size: u64, client: &Client, ) -> Result<Option<DriveItem>>

Upload bytes to an upload session

You can upload the entire file, or split the file into multiple byte ranges, as long as the maximum bytes in any given request is less than 60 MiB. The fragments of the file must be uploaded sequentially in order. Uploading fragments out of order will result in an error.

§Notes

If your app splits a file into multiple byte ranges, the size of each byte range MUST be a multiple of 320 KiB (327,680 bytes). Using a fragment size that does not divide evenly by 320 KiB will result in errors committing some files. The 60 MiB limit and 320 KiB alignment are not checked locally since they may change in the future.

The file_size of all part upload requests should be identical.

§Results
  • If the part is uploaded successfully, but the file is not complete yet, will return None.
  • If this is the last part and it is uploaded successfully, will return Some(<newly_created_drive_item>).
§Errors

When the file is completely uploaded, if an item with the same name is created during uploading, the last upload_to_session call will return Err with HTTP 409 CONFLICT.

§Panics

Panic if remote_range is invalid or not match the length of data.

§See also

Microsoft Docs

Trait Implementations§

Source§

impl Debug for UploadSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,