@@ -50,17 +50,20 @@ class ApiService {
5050 protected $ documentService ;
5151 protected $ logger ;
5252 private $ imageService ;
53+ private $ encodingService ;
5354
5455 public function __construct (IRequest $ request ,
5556 SessionService $ sessionService ,
5657 DocumentService $ documentService ,
5758 ImageService $ imageService ,
59+ EncodingService $ encodingService ,
5860 ILogger $ logger ) {
5961 $ this ->request = $ request ;
6062 $ this ->sessionService = $ sessionService ;
6163 $ this ->documentService = $ documentService ;
6264 $ this ->logger = $ logger ;
6365 $ this ->imageService = $ imageService ;
66+ $ this ->encodingService = $ encodingService ;
6467 }
6568
6669 public function create ($ fileId = null , $ filePath = null , $ token = null , $ guestName = null , bool $ forceRecreate = false ): DataResponse {
@@ -105,6 +108,11 @@ public function create($fileId = null, $filePath = null, $token = null, $guestNa
105108 try {
106109 $ baseFile = $ this ->documentService ->getBaseFile ($ document ->getId ());
107110 $ content = $ baseFile ->getContent ();
111+
112+ $ content = $ this ->encodingService ->encodeToUtf8 ($ content );
113+ if (!$ content ) {
114+ $ this ->logger ->log (ILogger::WARN , 'Failed to encode file to UTF8. File ID: ' . $ file ->getId ());
115+ }
108116 } catch (NotFoundException $ e ) {
109117 $ this ->logger ->logException ($ e , ['level ' => ILogger::INFO ]);
110118 $ content = null ;
0 commit comments