From 9d88fbd52d1b66c36a7872387beee47808ee4b86 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Mon, 14 Oct 2019 16:53:27 +0100 Subject: [PATCH] FIX #11875 TIME 0:05 rm control size + change return in scan context --- src/app/convert/controllers/ConvertPdfController.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/app/convert/controllers/ConvertPdfController.php b/src/app/convert/controllers/ConvertPdfController.php index f356891fb62..72166d52ae9 100755 --- a/src/app/convert/controllers/ConvertPdfController.php +++ b/src/app/convert/controllers/ConvertPdfController.php @@ -164,11 +164,11 @@ class ConvertPdfController $resource = file_get_contents("{$tmpPath}{$tmpFilename}.pdf"); $aReturn = []; - $aReturn["encodedResource"] = base64_encode($resource); if ($aArgs['context'] == 'scan') { $aReturn["tmpFilename"] = $tmpFilename.'.pdf'; } else { + $aReturn["encodedResource"] = base64_encode($resource); unlink("{$tmpPath}{$tmpFilename}.pdf"); } return $aReturn; @@ -245,24 +245,22 @@ class ConvertPdfController $size = strlen($file); if (strtolower($ext) == 'pdf' && strtolower($mimeType) == 'application/pdf') { - $return['encodedResource'] = $body['base64']; if ($body['context'] == 'scan') { $tmpPath = CoreConfigModel::getTmpPath(); $tmpFilename = 'scan_converting' . rand() . '.pdf'; file_put_contents($tmpPath . $tmpFilename, $file); $return['tmpFilename'] = $tmpFilename; + } else { + $return['encodedResource'] = $body['base64']; } return $response->withJson($return); } else { $fileAccepted = StoreController::isFileAllowed(['extension' => $ext, 'type' => $mimeType]); - $maxFilesizeMo = ini_get('upload_max_filesize'); $canConvert = ConvertPdfController::canConvert(['extension' => $ext]); if (!$fileAccepted) { return $response->withStatus(400)->withJson(['errors' => 'File type not allowed. Extension : ' . $ext . '. Mime Type : ' . $mimeType . '.']); - } elseif ($size/1024 > $maxFilesizeMo*1024) { - return $response->withStatus(400)->withJson(['errors' => 'File maximum size is exceeded ('.$maxFilesizeMo.' Mo)']); } elseif (!$canConvert) { return $response->withStatus(400)->withJson(['errors' => 'File accepted but can not be converted in pdf']); } -- GitLab