upyun_sdk/rest_type.rs
1use serde::{Serialize, Deserialize};
2
3/// 获取文件信息的响应信息
4#[derive(Debug, Clone)]
5pub struct FileInfo {
6 /// 文件为 `file`,文件夹为 `folder`
7 pub x_upyun_file_type: String,
8 /// 文件大小(字节)
9 pub x_upyun_file_size: Option<u64>,
10 /// 文件创建时间
11 pub x_upyun_file_date: String,
12 /// 文件的 MD5 值
13 pub content_md5: Option<String>,
14}
15
16/// 获取目录文件列表的参数
17pub struct ListDirParams {
18 /// 分页开始位置,通过 `x-upyun-list-iter` 响应头返回,所以第一次请求不需要填写
19 pub x_list_iter: Option<String>,
20 /// 获取的文件数量,默认 100,最大 10000
21 pub x_list_limit: Option<u64>,
22 /// `asc` 或 `desc`,按文件名升序或降序排列。默认 `asc``
23 pub x_list_order: Option<String>
24}
25
26/// 目录文件列表的元素
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct DirElem {
29 /// 目录/文件的类型。如果是目录,则为 `folder`,如果是文件,则为文件的类型,
30 pub r#type: String,
31 /// 文件大小(字节)
32 pub length: u64,
33 /// 文件/目录名
34 pub name: String,
35 /// 最后修改时间
36 pub last_modified: u64
37}
38
39/// 获取目录文件列表的响应信息
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub struct ListDir {
42 /// 各个文件/目录的信息
43 pub files: Vec<DirElem>,
44 /// 返回下一次分页开始位置。它由一串 Base64 编码的随机数组成,当它是 g2gCZAAEbmV4dGQAA2VvZg 时,表示最后一个分页。
45 pub iter: String
46}
47
48/// 复制文件的参数
49pub struct CopyParams {
50 /// 源文件地址(同 bucket),格式 `/<source_to_file>`
51 pub source_path: String,
52 /// 处理源文件的元信息,默认 `copy`(复制),详见 [Metadata](https://help.upyun.com/knowledge-base/rest_api/#metadata)
53 pub x_upyun_metadata_directive: Option<String>,
54 /// 请求的 MD5 值,需要服务端进行 MD5 校验请填写,等效于[签名认证](https://help.upyun.com/knowledge-base/object_storage_authorization/#sign_auth)中的 Content-MD5
55 pub content_md5: Option<String>
56}
57
58/// 移动文件的参数
59pub struct MoveParams {
60 /// 需要移动的文件地址(同 bucket),格式 `/<source_to_file>`
61 pub source_path: String,
62 /// 处理源文件的元信息,默认 `copy`(复制),详见 [Metadata](https://help.upyun.com/knowledge-base/rest_api/#metadata)
63 pub x_upyun_metadata_directive: Option<String>,
64 /// 请求的 MD5 值,需要服务端进行 MD5 校验请填写,等效于[签名认证](https://help.upyun.com/knowledge-base/object_storage_authorization/#sign_auth)中的 Content-MD5
65 pub content_md5: Option<String>
66}
67
68/// 上传文件的参数
69pub struct UploadParams {
70 /// 文件类型,默认使用文件扩展名作为文件类型
71 pub content_type: Option<String>,
72 /// 上传文件的 MD5 值,如果请求中文件太大计算 MD5 不方便,可以为空
73 pub content_md5: Option<String>,
74 /// 文件密钥,用于保护文件,防止文件被直接访问,见 [Content-Secret 参数说明](https://help.upyun.com/knowledge-base/rest_api/#Content-Secret)
75 pub content_secret: Option<String>,
76 /// 文件元信息,见 [Metadata](https://help.upyun.com/knowledge-base/rest_api/#metadata)
77 pub x_upyun_meta_x: Option<String>,
78 /// 文件元信息, 指定文件的生存时间,单位天,最大支持180天,见 [Metadata](https://help.upyun.com/knowledge-base/rest_api/#metadata)
79 pub x_upyun_meta_ttl: Option<u64>,
80 /// 图片预处理参数,见[上传预处理(同步)](https://help.upyun.com/knowledge-base/image/#sync_upload_process)
81 pub x_gmkerl_thumb: Option<String>
82
83}