Skip to content
Snippets Groups Projects
Commit b77df9d7 authored by Александр Плохих's avatar Александр Плохих :waxing_gibbous_moon:
Browse files

chenge logic to get and read files

parent 106913cf
No related branches found
No related tags found
1 merge request!8make controller
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Controller; namespace App\Controller;
use App\Actions\ReadLogFileAction; use App\Actions\ReadLogFileAction;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
...@@ -13,15 +14,16 @@ class ReadLogFileController extends AbstractController ...@@ -13,15 +14,16 @@ class ReadLogFileController extends AbstractController
* проверяет, что файл существует и выводит пользователю весь контент файла * проверяет, что файл существует и выводит пользователю весь контент файла
* (файл можешь создать любой) * (файл можешь создать любой)
* *
* @param string $filePath путь до файла * @param Request $request
* @return Response */ * @param ReadLogFileAction $action
#[Route('/read/{filePath}', name: 'app_read_log_file', methods: ['GET'])] * @return Response
public function index(string $filePath, ReadLogFileAction $action): Response */
#[Route('/read', name: 'app_read_log_file', methods: ['POST'])]
public function index(Request $request, ReadLogFileAction $action): Response
{ {
try { $file = $request->files->get("File");
return new Response($action->act($filePath)); return new Response($action->act($file->getPathname()));
} catch (\Exception $exception) {
return new Response('Searching file not found :/', 422);
}
} }
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment