Files
Nexora/app/Http/Controllers/PreviewController.php
Javi 356f56eebd
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
first commit
2025-04-23 00:14:33 +06:00

28 lines
677 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\DocumentVersion;
use Illuminate\Http\Request;
class PreviewController extends Controller
{
public function show(DocumentVersion $version)
{
$filePath = storage_path("app/{$version->file_path}");
return match($version->mime_type) {
'application/pdf' => response()->file($filePath),
'image/*' => response()->file($filePath),
default => response()->file(
$this->convertToPdf($filePath)
)
};
}
private function convertToPdf($filePath)
{
// Usar OnlyOffice o LibreOffice para conversión
}
}