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

chenge login to read file from req

parent 702c998d
Branches PTPS|Controller_9
No related tags found
1 merge request!9make controller
......@@ -4,6 +4,7 @@ namespace App\Controller;
use App\Actions\ReadFileLineByLineAction;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
......@@ -15,20 +16,21 @@ class ReadFileLineByLineController extends AbstractController
*
* @param string $filePath путь до файла
* @return Response */
#[Route('/readbyline/{filePath}', name: 'app_read_file_line_by_line')]
#[Route('/readbyline', name: 'app_read_file_line_by_line', methods: ['POST'])]
public function index(
string $filePath,
Request $request,
ReadFileLineByLineAction $action
) : Response {
$file = "";
$file = $request->files->get('File');
$content = "";
try{
foreach ($action->act($filePath) as $line) {
$file .= $line;
foreach ($action->act($file->getRealPath()) as $line) {
$content .= $line;
}
} catch (\Exception $exception) {
return new Response($exception->getMessage(), Response::HTTP_NOT_FOUND);
}
return new Response($file, Response::HTTP_OK);
return new Response($content);
}
}
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