@@ -35,6 +35,7 @@ pub(super) enum StmtParam {
3535 SqlPageVersion ,
3636 Literal ( String ) ,
3737 UploadedFilePath ( String ) ,
38+ UploadedFileMimeType ( String ) ,
3839 ReadFileAsText ( Box < StmtParam > ) ,
3940 ReadFileAsDataUrl ( Box < StmtParam > ) ,
4041 Path ,
@@ -95,6 +96,10 @@ pub(super) fn func_call_to_param(func_name: &str, arguments: &mut [FunctionArg])
9596 "protocol" => StmtParam :: Protocol ,
9697 "uploaded_file_path" => extract_single_quoted_string ( "uploaded_file_path" , arguments)
9798 . 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+ }
98103 "read_file_as_text" => StmtParam :: ReadFileAsText ( Box :: new ( extract_variable_argument (
99104 "read_file_as_text" ,
100105 arguments,
@@ -244,7 +249,7 @@ async fn read_file_as_data_url<'a>(
244249}
245250
246251fn 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 {
248253 request. uploaded_files . get ( name) ?. content_type . as_ref ( )
249254 } else {
250255 None
@@ -296,6 +301,12 @@ pub(super) fn extract_req_param_non_nested<'a>(
296301 . get ( x)
297302 . and_then ( |x| x. file . path ( ) . to_str ( ) )
298303 . 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 ) ,
299310 StmtParam :: ReadFileAsText ( _) => bail ! ( "Nested read_file_as_text() function not allowed" , ) ,
300311 StmtParam :: ReadFileAsDataUrl ( _) => {
301312 bail ! ( "Nested read_file_as_data_url() function not allowed" , )
0 commit comments