@@ -17,14 +17,14 @@ use tokio::{
1717use tokio_util:: io:: StreamReader ;
1818use tracing:: debug;
1919
20+ use crate :: upload:: ConvertType ;
2021use crate :: {
2122 common:: {
2223 constant:: { SHARE_DRIVE_PATH_BUF , THUMB_H , THUMB_W , TMP_FS_PATH } ,
2324 domain:: ServiceError ,
2425 util:: { IdGenerator , StoreCollection } ,
2526 } ,
2627 store:: { Repository , StoreClient , StoreRepository , get_document_filter_by_maybe_object_id} ,
27- upload:: soffice:: { ConvertType , convert_to} ,
2828} ;
2929
3030use super :: domain:: FileUploadV2 ;
@@ -88,7 +88,7 @@ impl FileService {
8888 . map_err ( ServiceError :: new)
8989 . map ( |im| ( upl. content_type . clone ( ) , im) )
9090 } else {
91- match convert_to ( temp_file_path, ConvertType :: Png )
91+ match super :: imagemagick :: convert_to ( temp_file_path, ConvertType :: Png )
9292 . await
9393 . map_err ( ServiceError :: new)
9494 . map ( |bytes| {
@@ -99,11 +99,28 @@ impl FileService {
9999 Ok ( img) => img,
100100 Err ( e) => {
101101 tracing:: error!(
102- "error converting file {}: {}, giving up ..." ,
102+ "error converting file {}: {}, trying with soffice ..." ,
103103 internal_name,
104104 e
105105 ) ;
106- return Ok ( None ) ;
106+ match super :: soffice:: convert_to ( temp_file_path, ConvertType :: Png )
107+ . await
108+ . map_err ( ServiceError :: new)
109+ . map ( |bytes| {
110+ image:: load_from_memory ( & bytes)
111+ . map_err ( ServiceError :: new)
112+ . map ( |im| ( Some ( IMAGE_PNG . to_string ( ) ) , im) )
113+ } ) {
114+ Ok ( img) => img,
115+ Err ( e) => {
116+ tracing:: error!(
117+ "error converting file {}: {}, giving up..." ,
118+ internal_name,
119+ e
120+ ) ;
121+ return Ok ( None ) ;
122+ }
123+ }
107124 }
108125 }
109126 } ?;
0 commit comments