@@ -35,6 +35,7 @@ pub(super) enum StmtParam {
35
35
SqlPageVersion ,
36
36
Literal ( String ) ,
37
37
UploadedFilePath ( String ) ,
38
+ UploadedFileMimeType ( String ) ,
38
39
ReadFileAsText ( Box < StmtParam > ) ,
39
40
ReadFileAsDataUrl ( Box < StmtParam > ) ,
40
41
Path ,
@@ -95,6 +96,10 @@ pub(super) fn func_call_to_param(func_name: &str, arguments: &mut [FunctionArg])
95
96
"protocol" => StmtParam :: Protocol ,
96
97
"uploaded_file_path" => extract_single_quoted_string ( "uploaded_file_path" , arguments)
97
98
. map_or_else ( StmtParam :: Error , StmtParam :: UploadedFilePath ) ,
99
+ "uploaded_file_mime_type" => {
100
+ extract_single_quoted_string ( "uploaded_file_mime_type" , arguments)
101
+ . map_or_else ( StmtParam :: Error , StmtParam :: UploadedFileMimeType )
102
+ }
98
103
"read_file_as_text" => StmtParam :: ReadFileAsText ( Box :: new ( extract_variable_argument (
99
104
"read_file_as_text" ,
100
105
arguments,
@@ -244,7 +249,7 @@ async fn read_file_as_data_url<'a>(
244
249
}
245
250
246
251
fn mime_from_upload < ' a > ( param0 : & StmtParam , request : & ' a RequestInfo ) -> Option < & ' a Mime > {
247
- if let StmtParam :: UploadedFilePath ( name) = param0 {
252
+ if let StmtParam :: UploadedFilePath ( name) | StmtParam :: UploadedFileMimeType ( name ) = param0 {
248
253
request. uploaded_files . get ( name) ?. content_type . as_ref ( )
249
254
} else {
250
255
None
@@ -296,6 +301,12 @@ pub(super) fn extract_req_param_non_nested<'a>(
296
301
. get ( x)
297
302
. and_then ( |x| x. file . path ( ) . to_str ( ) )
298
303
. map ( Cow :: Borrowed ) ,
304
+ StmtParam :: UploadedFileMimeType ( x) => request
305
+ . uploaded_files
306
+ . get ( x)
307
+ . and_then ( |x| x. content_type . as_ref ( ) )
308
+ . map ( |x| x. as_ref ( ) )
309
+ . map ( Cow :: Borrowed ) ,
299
310
StmtParam :: ReadFileAsText ( _) => bail ! ( "Nested read_file_as_text() function not allowed" , ) ,
300
311
StmtParam :: ReadFileAsDataUrl ( _) => {
301
312
bail ! ( "Nested read_file_as_data_url() function not allowed" , )
0 commit comments