From b77df9d723244238983f1e9adeecf3709f7d8c64 Mon Sep 17 00:00:00 2001
From: "Alex. Plokhikh" <a.plohih@iqdev.digital>
Date: Wed, 17 Apr 2024 10:58:59 +0500
Subject: [PATCH] chenge logic to get and read files

---
 src/Controller/ReadLogFileController.php | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/Controller/ReadLogFileController.php b/src/Controller/ReadLogFileController.php
index 263ab11..809cf64 100644
--- a/src/Controller/ReadLogFileController.php
+++ b/src/Controller/ReadLogFileController.php
@@ -3,6 +3,7 @@
 namespace App\Controller;
 use App\Actions\ReadLogFileAction;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\Routing\Attribute\Route;
 
@@ -13,15 +14,16 @@ class ReadLogFileController extends AbstractController
      * проверяет, что файл существует и выводит пользователю весь контент файла
      * (файл можешь создать любой)
      *
-     * @param string $filePath путь до файла
-     * @return Response */
-    #[Route('/read/{filePath}', name: 'app_read_log_file', methods: ['GET'])]
-    public function index(string $filePath, ReadLogFileAction $action): Response
+     * @param Request $request
+     * @param ReadLogFileAction $action
+     * @return Response
+     */
+    #[Route('/read', name: 'app_read_log_file', methods: ['POST'])]
+    public function index(Request $request, ReadLogFileAction $action): Response
     {
-        try {
-            return new Response($action->act($filePath));
-        } catch (\Exception $exception) {
-            return new Response('Searching file not found :/', 422);
-        }
+        $file = $request->files->get("File");
+        return new Response($action->act($file->getPathname()));
     }
-}
+
+    }
+
-- 
GitLab