qiniu_upload_manager/single_part_uploader/
mod.rs

1use super::{ObjectParams, UploadManager, UploaderWithCallbacks};
2use qiniu_apis::http_client::ApiResult;
3use serde_json::Value;
4use std::{fmt::Debug, io::Read, path::Path};
5
6#[cfg(feature = "async")]
7use futures::{future::BoxFuture, AsyncRead};
8
9/// 单请求上传器接口
10///
11/// 仅通过一次 HTTP 请求即上传整个数据源,适合数据量较小的数据源,不提供断点恢复的能力。
12pub trait SinglePartUploader: __private::Sealed + UploaderWithCallbacks + Clone + Sync + Send + Debug {
13    /// 创建单请求上传器
14    fn new(upload_manager: UploadManager) -> Self;
15
16    /// 上传指定路径的文件
17    ///
18    /// 该方法的异步版本为 [`Self::async_upload_path`]。
19    fn upload_path(&self, path: impl AsRef<Path>, params: ObjectParams) -> ApiResult<Value>;
20
21    /// 上传输入流的数据
22    ///
23    /// 该方法的异步版本为 [`Self::async_upload_reader`]。
24    fn upload_reader<R: Read + 'static>(&self, reader: R, params: ObjectParams) -> ApiResult<Value>;
25
26    /// 异步上传指定路径的文件
27    #[cfg(feature = "async")]
28    #[cfg_attr(feature = "docs", doc(cfg(feature = "async")))]
29    fn async_upload_path<'a>(
30        &'a self,
31        path: impl AsRef<Path> + Send + Sync + 'a,
32        params: ObjectParams,
33    ) -> BoxFuture<'a, ApiResult<Value>>;
34
35    /// 上传异步输入流的数据
36    #[cfg(feature = "async")]
37    #[cfg_attr(feature = "docs", doc(cfg(feature = "async")))]
38    fn async_upload_reader<R: AsyncRead + Unpin + Send + Sync + 'static>(
39        &self,
40        reader: R,
41        params: ObjectParams,
42    ) -> BoxFuture<ApiResult<Value>>;
43}
44
45mod form_uploader;
46pub use form_uploader::FormUploader;
47
48mod __private {
49    pub trait Sealed {}
50}