Skip to main content

MultipartUpload

Struct MultipartUpload 

Source
pub struct MultipartUpload {
    pub upload_id: String,
    pub key: String,
    pub content_type: String,
    pub parts: Vec<Part>,
    pub expected_parts: u32,
    pub part_size: usize,
    pub status: UploadStatus,
    pub created_at: u64,
}
Expand description

分片上传会话

Fields§

§upload_id: String

上传 ID

§key: String

目标对象 key

§content_type: String

Content-Type

§parts: Vec<Part>

已上传的分片列表

§expected_parts: u32

预期的总分片数

§part_size: usize

每个分片的大小阈值(字节)

§status: UploadStatus

上传状态

§created_at: u64

创建时间戳(秒)

Implementations§

Source§

impl MultipartUpload

Source

pub fn new( key: impl Into<String>, content_type: impl Into<String>, part_size: usize, ) -> Self

创建新的分片上传会话

Source

pub fn upload_part( &mut self, number: u32, data: Vec<u8>, ) -> Result<String, StorageError>

上传一个分片

Source

pub fn complete(&mut self) -> Result<Vec<u8>, StorageError>

完成分片上传,返回合并后的完整数据

Source

pub fn abort(&mut self) -> Result<(), StorageError>

中止分片上传

Source

pub fn uploaded_part_count(&self) -> usize

返回已上传分片数量

Source

pub fn uploaded_bytes(&self) -> usize

返回已上传字节数

Source

pub fn progress_percent(&self) -> u8

返回上传进度百分比(0-100)

Source

pub fn is_completed(&self) -> bool

判断上传是否已完成

Trait Implementations§

Source§

impl Debug for MultipartUpload

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for MultipartUpload

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for MultipartUpload

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.