pub struct GetObject { /* private fields */ }Expand description
Retrieve the object’s content
See the Alibaba Cloud documentation for details
Implementations§
Source§impl GetObject
impl GetObject
Sourcepub fn set_range(self, start: usize, end: Option<usize>) -> Self
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
Sourcepub fn set_if_modified_since(self, if_modified_since: OffsetDateTime) -> Self
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
Sourcepub fn set_if_unmodified_since(
self,
if_unmodified_since: OffsetDateTime,
) -> Self
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
Sourcepub fn set_if_match(self, if_match: impl ToString) -> Self
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
Sourcepub fn set_if_none_match(self, if_none_match: impl ToString) -> Self
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
Sourcepub async fn download_to_file(self, save_path: &str) -> Result<(), Error>
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
Sourcepub async fn download(self) -> Result<Bytes, Error>
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
Sourcepub async fn download_to_stream(
self,
) -> Result<Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Send>>, Error>
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),
}
}