isMethod('POST')) { /** @var UploadedFile $file */ $file = $request->files->get('file'); if ($file && $file->getClientOriginalExtension() === 'cbr') { $originalFileName = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME); $tempFilePath = $file->getPathname(); try { $cbzPath = $this->cbrToCbzConverter->convert($tempFilePath); $response = new BinaryFileResponse($cbzPath); $response->setContentDisposition( ResponseHeaderBag::DISPOSITION_ATTACHMENT, $originalFileName . '.cbz' ); $response->headers->set('Content-Type', 'application/x-cbz'); $response->headers->set('Turbo-Visit-Control', 'reload'); $response->deleteFileAfterSend(true); return $response; } catch (\Exception $e) { $this->notificationService->sendUpdate([ 'status' => 'error', 'message' => 'Une erreur est survenue lors de la conversion : ' . $e->getMessage() ]); } } else { $this->notificationService->sendUpdate([ 'status' => 'error', 'message' => 'Veuillez sélectionner un fichier CBR valide.' ]); } } return $this->render('conversion/index.html.twig'); } }