ncjoes / office-converter

PHP Wrapper for LibreOffice
MIT License
220 stars 78 forks source link

Error throwing: File does not exists but It exists on AWS S3 bucket #22

Open itsdeo opened 4 years ago

itsdeo commented 4 years ago

Hi There,

I am implementing Office-converter to convert PPT to PDF but I am getting error like

message: File does not exist --http://s3-eu-west-2.amazonaws.com/SomeDirName/SomeFile.ppt I checked file is exists but showing above error message.

I used code like : $converter = new OfficeConverter($request->s3_url); $converter->convertTo('output_file.pdf'); //generates pdf file in same directory as test-file.docx

Please help me on this

Thank you!

php- commented 3 years ago

Looking for the same case, Any help?

fd6130 commented 2 years ago

Wait.. Isn't it this library only works in local filesystem? I think you need to download the s3 file to a temp path and use that path to convert.

Meet0001 commented 6 months ago

You can download the file from s3 into your local machine using the following code. function loadFile($templateFile,$fields,$results){ try{ $headers = @getheaders($templateFile); if ($headers && strpos($headers[0], '200') !== false) { $localfilepath = envpath("common"). "assets/tmp/dummy". time() . ".pptx"; if($contents = file_get_contents($templateFile)){ file_put_contents($localfilepath, $contents); } } } }

After all the processing, you can delete the downloaded file using unlink function.