xt_oss/oss/entities/
callback.rs

1use serde::{Deserialize, Serialize};
2use std::fmt;
3#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default)]
4pub enum CallbackBodyType {
5    FormUrlEncoded,
6    #[default]
7    JSON,
8}
9
10impl fmt::Display for CallbackBodyType {
11    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12        match self {
13            Self::FormUrlEncoded => write!(f, "{}", "a"),
14            Self::JSON => write!(f, "{}", "b"),
15        }
16    }
17}
18
19#[derive(Debug, Serialize, Deserialize, Default, Clone)]
20pub struct CallbackBody {
21    /// 存储空间名称。
22    pub bucket: String,
23    ///对象(文件)的完整路径。
24    pub object: String,
25    /// 文件的ETag,即返回给用户的ETag字段。
26    pub etag: String,
27    /// Object大小。调用CompleteMultipartUpload时,size为整个Object的大小。
28    pub size: String,
29    /// 资源类型,例如jpeg图片的资源类型为image/jpeg。
30    pub mime_type: String,
31    /// 图片高度。该变量仅适用于图片格式,对于非图片格式,该变量的值为空。
32    pub imageinfo_height: String,
33    /// 图片宽度。该变量仅适用于图片格式,对于非图片格式,该变量的值为空。
34    pub imageinfo_width: String,
35    /// 图片格式,例如JPG、PNG等。该变量仅适用于图片格式,对于非图片格式,该变量的值为空。
36    pub imageinfo_format: String,
37    /// 与上传文件后返回的x-oss-hash-crc64ecma头内容一致。
38    pub crc64: String,
39    /// 与上传文件后返回的Content-MD5头内容一致。 仅在调用PutObject和PostObject接口上传文件时,该变量的值不为空。
40    pub content_md5: String,
41    /// 发起请求的客户端所在的VpcId。如果不是通过VPC发起请求,则该变量的值为空。
42    pub vpc_id: String,
43    /// 发起请求的客户端IP地址。
44    pub client_ip: String,
45    /// 发起请求的RequestId。
46    pub req_id: String,
47    /// 发起请求的接口名称,例如PutObject、PostObject等。
48    pub operation: String,
49}
50
51#[derive(Debug, Serialize, Deserialize, Default, Clone)]
52pub struct Callback {
53    pub callback_url: String,
54    pub callback_host: Option<String>,
55    pub callback_body: CallbackBody,
56    pub callback_sni: Option<String>,
57    pub callback_body_type: Option<CallbackBodyType>,
58}