Files
ninedad/src/Controller/FileController.php

27 lines
791 B
PHP
Raw Normal View History

2025-07-28 17:38:40 +02:00
<?php
namespace App\Controller;
use App\Service\FileService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class FileController extends AbstractController
{
#[Route('/user/file/{id}', name: 'app_files', methods: ['GET'])]
public function browse(int $id, Request $request, FileService $fileService): JsonResponse
{
$relativePath = $request->query->get('path', '');
try {
$files = $fileService->list($id, '');
return $this->json(['files' => $files]);
} catch (\Exception $e) {
return $this->json(['error' => $e->getMessage()], 400);
}
}
}