Trait qiniu_sdk::prelude::MultiPartsUploader
source · [−]pub trait MultiPartsUploader: MultiPartsUploaderWithCallbacks + Send + Sync + Debug {
type ResumableRecorder: 'static + ResumableRecorder;
type InitializedParts: 'static + InitializedParts;
type UploadedPart: 'static + UploadedPart;
fn new(
upload_manager: UploadManager,
resumable_recorder: Self::ResumableRecorder
) -> Self;
fn initialize_parts<D>(
&self,
source: D,
params: ObjectParams
) -> Result<Self::InitializedParts, Error>
where
D: 'static + DataSource<<Self::ResumableRecorder as ResumableRecorder>::HashAlgorithm>;
fn upload_part(
&self,
initialized: &Self::InitializedParts,
data_partitioner_provider: &dyn DataPartitionProvider
) -> Result<Option<Self::UploadedPart>, Error>;
fn complete_parts(
&self,
initialized: Self::InitializedParts,
parts: Vec<Self::UploadedPart, Global>
) -> Result<Value, Error>;
fn async_initialize_parts<D>(
&self,
source: D,
params: ObjectParams
) -> Pin<Box<dyn Future<Output = Result<Self::InitializedParts, Error>> + Send, Global>>
where
D: 'static + DataSource<<Self::ResumableRecorder as ResumableRecorder>::HashAlgorithm>;
fn async_upload_part(
&'r self,
initialized: &'r Self::InitializedParts,
data_partitioner_provider: &'r (dyn DataPartitionProvider + 'r)
) -> Pin<Box<dyn Future<Output = Result<Option<Self::UploadedPart>, Error>> + Send + 'r, Global>>;
fn async_complete_parts(
&self,
initialized: Self::InitializedParts,
parts: Vec<Self::UploadedPart, Global>
) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send, Global>>;
}
Expand description
分片上传器接口
将数据源通过多个分片的方式逐一上传,适合数据量较大的数据源,可以提供断点恢复的能力。
Required Associated Types
type ResumableRecorder: 'static + ResumableRecorder
type ResumableRecorder: 'static + ResumableRecorder
断点恢复记录器
type InitializedParts: 'static + InitializedParts
type InitializedParts: 'static + InitializedParts
初始化的分片信息
type UploadedPart: 'static + UploadedPart
type UploadedPart: 'static + UploadedPart
已经上传的分片信息
Required Methods
fn new(
upload_manager: UploadManager,
resumable_recorder: Self::ResumableRecorder
) -> Self
fn new(
upload_manager: UploadManager,
resumable_recorder: Self::ResumableRecorder
) -> Self
创建分片上传器
fn initialize_parts<D>(
&self,
source: D,
params: ObjectParams
) -> Result<Self::InitializedParts, Error> where
D: 'static + DataSource<<Self::ResumableRecorder as ResumableRecorder>::HashAlgorithm>,
fn initialize_parts<D>(
&self,
source: D,
params: ObjectParams
) -> Result<Self::InitializedParts, Error> where
D: 'static + DataSource<<Self::ResumableRecorder as ResumableRecorder>::HashAlgorithm>,
fn upload_part(
&self,
initialized: &Self::InitializedParts,
data_partitioner_provider: &dyn DataPartitionProvider
) -> Result<Option<Self::UploadedPart>, Error>
fn upload_part(
&self,
initialized: &Self::InitializedParts,
data_partitioner_provider: &dyn DataPartitionProvider
) -> Result<Option<Self::UploadedPart>, Error>
fn complete_parts(
&self,
initialized: Self::InitializedParts,
parts: Vec<Self::UploadedPart, Global>
) -> Result<Value, Error>
fn complete_parts(
&self,
initialized: Self::InitializedParts,
parts: Vec<Self::UploadedPart, Global>
) -> Result<Value, Error>
fn async_initialize_parts<D>(
&self,
source: D,
params: ObjectParams
) -> Pin<Box<dyn Future<Output = Result<Self::InitializedParts, Error>> + Send, Global>> where
D: 'static + DataSource<<Self::ResumableRecorder as ResumableRecorder>::HashAlgorithm>,
fn async_initialize_parts<D>(
&self,
source: D,
params: ObjectParams
) -> Pin<Box<dyn Future<Output = Result<Self::InitializedParts, Error>> + Send, Global>> where
D: 'static + DataSource<<Self::ResumableRecorder as ResumableRecorder>::HashAlgorithm>,
异步初始化分片信息
该步骤只负责初始化分片,但不实际上传数据,如果提供了有效的断点续传记录器,则可以尝试在这一步找到记录。
fn async_upload_part(
&'r self,
initialized: &'r Self::InitializedParts,
data_partitioner_provider: &'r (dyn DataPartitionProvider + 'r)
) -> Pin<Box<dyn Future<Output = Result<Option<Self::UploadedPart>, Error>> + Send + 'r, Global>>
fn async_upload_part(
&'r self,
initialized: &'r Self::InitializedParts,
data_partitioner_provider: &'r (dyn DataPartitionProvider + 'r)
) -> Pin<Box<dyn Future<Output = Result<Option<Self::UploadedPart>, Error>> + Send + 'r, Global>>
异步上传分片
实际上传的分片大小由提供的分片大小提供者获取。
如果返回 [Ok(None)
] 则表示已经没有更多分片可以上传。
fn async_complete_parts(
&self,
initialized: Self::InitializedParts,
parts: Vec<Self::UploadedPart, Global>
) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send, Global>>
fn async_complete_parts(
&self,
initialized: Self::InitializedParts,
parts: Vec<Self::UploadedPart, Global>
) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send, Global>>
异步完成分片上传
在这步成功返回后,对象即可被读取。