utapi_rs/models/
upload_files.rs

1use std::{collections::HashMap, path::PathBuf};
2
3#[derive(serde::Serialize)]
4pub enum ContentDisposition {
5    Inline,
6    Attachment,
7}
8
9#[derive(serde::Serialize)]
10pub enum Acl {
11    Private,
12    PublicRead,
13}
14
15#[derive(Debug)]
16pub struct FileObj {
17    pub name: String,
18    pub path: PathBuf,
19}
20
21#[derive(serde::Serialize)]
22pub struct UploadFileOpts {
23    pub metadata: Option<HashMap<String, String>>,
24    #[serde(rename(serialize = "contentDisposition"))]
25    pub content_disposition: Option<ContentDisposition>,
26    pub acl: Option<Acl>,
27}
28
29#[derive(Debug, serde::Deserialize, Clone)]
30pub struct UploadFileResponse {
31    pub data: Vec<UploadFileResponseData>,
32}
33
34#[derive(Debug, serde::Deserialize, Clone)]
35pub struct UploadFileResponseData {
36    pub fields: serde_json::Value,
37    #[serde(rename = "fileUrl")]
38    pub file_url: String,
39    pub key: String,
40    #[serde(rename = "presignedUrl")]
41    pub presigned_url: String,
42    pub url: Option<String>,
43    pub urls: Option<Vec<String>>,
44    pub chunk_size: Option<u64>,
45}
46
47fn default_string() -> String {
48    String::new()
49}
50
51#[derive(Debug, serde::Deserialize)]
52pub struct Fields {
53    #[serde(rename = "Content-Disposition")]
54    pub content_disposition: String,
55    #[serde(rename = "Content-Type")]
56    pub content_type: String,
57    pub policy: String,
58    #[serde(rename = "X-Amz-Algorithm")]
59    pub x_amz_algorithm: String,
60    #[serde(rename = "X-Amz-Credential")]
61    pub x_amz_credential: String,
62    #[serde(rename = "X-Amz-Date")]
63    pub x_amz_date: String,
64    #[serde(rename = "X-Amz-Signature")]
65    pub x_amz_signature: String,
66    #[serde(default = "default_string")]
67    pub acl: String,
68    #[serde(default = "default_string")]
69    pub bucket: String,
70    #[serde(default = "default_string")]
71    pub key: String,
72}
73
74#[derive(Debug, serde::Deserialize, Clone)]
75pub struct FileUpload {
76    pub key: String,
77    pub url: String,
78    pub name: String,
79    pub size: u64,
80}