|
|
@ -12,6 +12,11 @@ use Symfony\Component\Process\Process; |
|
|
|
|
|
|
|
class FileController extends Controller |
|
|
|
{ |
|
|
|
public function __construct() |
|
|
|
{ |
|
|
|
$this->directoryPath = storage_path("app/contracts/"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @return JsonResponse |
|
|
@ -45,7 +50,7 @@ class FileController extends Controller |
|
|
|
|
|
|
|
Storage::disk('local')->put("contracts/{$originalFile}", file_get_contents($file)); // keep the original file
|
|
|
|
|
|
|
|
$process = new Process(['soffice', '--convert-to', 'xml', storage_path('app/contracts/' . $originalFile), '--outdir', storage_path('app/contracts/') . $fileId]); |
|
|
|
$process = new Process(['soffice', '--convert-to', 'xml', $this->directoryPath . $originalFile, '--outdir', $this->directoryPath . $fileId]); |
|
|
|
$process->run(); |
|
|
|
|
|
|
|
Storage::delete("contracts/{$originalFile}"); |
|
|
@ -71,15 +76,15 @@ class FileController extends Controller |
|
|
|
*/ |
|
|
|
public function convert(): JsonResponse |
|
|
|
{ |
|
|
|
$fileId = request()->input('file_id'); |
|
|
|
$file = (object) request()->input('file'); |
|
|
|
$searchers = request()->input('searchers'); |
|
|
|
|
|
|
|
$xml = storage_path() . "/app/contracts/{$fileId}/{$fileId}.xml"; |
|
|
|
$xml = $this->directoryPath . "{$file->id}/{$file->id}.xml"; |
|
|
|
|
|
|
|
(new SearchAndDisplaceXML($xml, $searchers))->execute(); |
|
|
|
(new SearchAndDisplaceXML($xml, $searchers, $file->type))->execute(); |
|
|
|
|
|
|
|
return response()->json([ |
|
|
|
'path' => 'tmp/' . $fileId . '.odt' |
|
|
|
'path' => "tmp/{$file->id}.{$file->type}" |
|
|
|
]); |
|
|
|
} |
|
|
|
|
|
|
|