first commit
This commit is contained in:
27
app/Http/Controllers/PreviewController.php
Normal file
27
app/Http/Controllers/PreviewController.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user