@@ -24,6 +24,8 @@ pub struct S3UploadMeta {
24
24
aws_region : String ,
25
25
#[ serde( default , deserialize_with = "deserialize_empty_object_as_string" ) ]
26
26
aws_bucket : String ,
27
+ #[ serde( default ) ]
28
+ aws_endpoint : String ,
27
29
}
28
30
29
31
fn deserialize_empty_object_as_string < ' de , D > ( deserializer : D ) -> Result < String , D :: Error >
@@ -82,12 +84,23 @@ impl S3UploadMeta {
82
84
& self . aws_bucket
83
85
}
84
86
85
- pub fn new ( id : String , user_id : String , aws_region : String , aws_bucket : String ) -> Self {
87
+ pub fn aws_endpoint ( & self ) -> & str {
88
+ & self . aws_endpoint
89
+ }
90
+
91
+ pub fn new (
92
+ id : String ,
93
+ user_id : String ,
94
+ aws_region : String ,
95
+ aws_bucket : String ,
96
+ aws_endpoint : String ,
97
+ ) -> Self {
86
98
Self {
87
99
id,
88
100
user_id,
89
101
aws_region,
90
102
aws_bucket,
103
+ aws_endpoint,
91
104
}
92
105
}
93
106
@@ -100,6 +113,10 @@ impl S3UploadMeta {
100
113
self . aws_bucket =
101
114
std:: env:: var ( "NEXT_PUBLIC_CAP_AWS_BUCKET" ) . unwrap_or_else ( |_| "capso" . to_string ( ) ) ;
102
115
}
116
+ if self . aws_endpoint . is_empty ( ) {
117
+ self . aws_endpoint = std:: env:: var ( "NEXT_PUBLIC_CAP_AWS_ENDPOINT" )
118
+ . unwrap_or_else ( |_| "https://s3.amazonaws.com" . to_string ( ) ) ;
119
+ }
103
120
}
104
121
}
105
122
@@ -110,6 +127,7 @@ struct S3UploadBody {
110
127
file_key : String ,
111
128
aws_bucket : String ,
112
129
aws_region : String ,
130
+ aws_endpoint : String ,
113
131
}
114
132
115
133
#[ derive( serde:: Serialize ) ]
@@ -197,6 +215,7 @@ pub async fn upload_video(
197
215
file_key : file_key. clone ( ) ,
198
216
aws_bucket : s3_config. aws_bucket ( ) . to_string ( ) ,
199
217
aws_region : s3_config. aws_region ( ) . to_string ( ) ,
218
+ aws_endpoint : s3_config. aws_endpoint ( ) . to_string ( ) ,
200
219
} ,
201
220
) ?;
202
221
@@ -350,6 +369,7 @@ pub async fn upload_image(app: &AppHandle, file_path: PathBuf) -> Result<Uploade
350
369
file_key : file_key. clone ( ) ,
351
370
aws_bucket : s3_config. aws_bucket ,
352
371
aws_region : s3_config. aws_region ,
372
+ aws_endpoint : s3_config. aws_endpoint ,
353
373
} ,
354
374
} ;
355
375
@@ -417,6 +437,7 @@ pub async fn upload_audio(app: &AppHandle, file_path: PathBuf) -> Result<Uploade
417
437
file_key : file_key. clone ( ) ,
418
438
aws_bucket : s3_config. aws_bucket . clone ( ) ,
419
439
aws_region : s3_config. aws_region . clone ( ) ,
440
+ aws_endpoint : s3_config. aws_endpoint . clone ( ) ,
420
441
} ,
421
442
) ?;
422
443
@@ -717,6 +738,7 @@ pub async fn upload_individual_file(
717
738
file_key : file_key. clone ( ) ,
718
739
aws_bucket : s3_config. aws_bucket . clone ( ) ,
719
740
aws_region : s3_config. aws_region . clone ( ) ,
741
+ aws_endpoint : s3_config. aws_endpoint . clone ( ) ,
720
742
} ;
721
743
722
744
let ( upload_url, mut form) = if is_audio {
@@ -783,6 +805,7 @@ async fn prepare_screenshot_upload(
783
805
file_key : file_key. clone ( ) ,
784
806
aws_bucket : s3_config. aws_bucket . clone ( ) ,
785
807
aws_region : s3_config. aws_region . clone ( ) ,
808
+ aws_endpoint : s3_config. aws_endpoint . clone ( ) ,
786
809
} ,
787
810
} ;
788
811
0 commit comments