learning-center/app/SharedKernel/File/Controllers/ImagePreviewController.php
2024-09-08 13:48:26 +03:00

21 lines
501 B
PHP

<?php
declare(strict_types=1);
namespace App\SharedKernel\File\Controllers;
use App\SharedKernel\File\Models\FileRepository;
final class ImagePreviewController extends \Phalcon\Mvc\Controller
{
public function mainAction($id): void
{
$file = (new FileRepository())->get($id);
header('Cache-Control: No-Store');
header('Content-Type:' . $file->mime_type);
header('Content-Length: ' . filesize($file->placement));
readfile($file->placement);
}
}