GetObject

Struct GetObject 

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

Retrieve the object’s content

See the Alibaba Cloud documentation for details

Implementations§

Source§

impl GetObject

Source

pub fn set_range(self, start: usize, end: Option<usize>) -> Self

Set the response range

end must be greater than or equal to start and both must be within the valid range; invalid values result in downloading the entire file

Byte indexing starts at 0; for a 500-byte file, the range is 0-499

Source

pub fn set_if_modified_since(self, if_modified_since: OffsetDateTime) -> Self

If the specified time is earlier than the actual modification time, the request succeeds

Source

pub fn set_if_unmodified_since( self, if_unmodified_since: OffsetDateTime, ) -> Self

If the specified time is equal to or later than the actual modification time, the request succeeds

Source

pub fn set_if_match(self, if_match: impl ToString) -> Self

If the provided ETag matches the object’s ETag, the request succeeds

The ETag verifies whether the data has changed and can be used to check data integrity

Source

pub fn set_if_none_match(self, if_none_match: impl ToString) -> Self

If the provided ETag differs from the object’s ETag, the request succeeds

Source

pub async fn download_to_file(self, save_path: &str) -> Result<(), Error>

Download the object to disk

Network paths are not supported. For SMB/NFS and similar storage, mount locally and use the local path

Source

pub async fn download(self) -> Result<Bytes, Error>

Download the object and return the content

If the object is large, this method may use too much memory; use with caution

Source

pub async fn download_to_stream( self, ) -> Result<Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Send>>, Error>

Download the object and return a data stream

Use this if the object is large and you do not want to save directly to a file; process the stream yourself

use futures_util::StreamExt;

let mut stream = object.get_object().download_to_stream().await.unwrap();
while let Some(item) = stream.next().await {
    match item {
        Ok(bytes) => {
            // Do something with bytes...
        }
        Err(e) => eprintln!("Error: {}", e),
    }
}

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> Same for T

Source§

type Output = T

Should always be Self
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