svg
This commit is contained in:
26
src/Controller/FileController.php
Normal file
26
src/Controller/FileController.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user