From abdb0f146f0bc2248df9b969ec6aef4b4a72fb03 Mon Sep 17 00:00:00 2001 From: Orka Arnest CRUZE Date: Tue, 29 Nov 2022 15:52:45 +0100 Subject: [PATCH] closes #112 --- src/Listener/UploadListener.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Listener/UploadListener.php b/src/Listener/UploadListener.php index 84d35eb..13ca148 100644 --- a/src/Listener/UploadListener.php +++ b/src/Listener/UploadListener.php @@ -5,7 +5,6 @@ use Oneup\UploaderBundle\Event\PostUploadEvent; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\File\File; -use ZipArchive; /** * @author pprevautel @@ -70,6 +69,7 @@ private function checkArchive($file) { $maxFiles = 10000; $maxSize = 1000000000; // 1 GB + $oneGiga = 1000000000; $maxRatio = 20; // initialement on avait testé 10% mais c'était trop restrictif (https://github.com/IGNF/geotuileur-site/issues/47) $filename = $file->getFilename(); @@ -109,7 +109,7 @@ private function checkArchive($file) $size = $stats['size']; if ($size > $maxSize) { - throw new \Exception("La taille du fichier $filename excède $maxSize"); + throw new \Exception(sprintf("La taille du fichier $filename excède %s GB", $maxSize / $oneGiga)); } if ($stats['comp_size']) { @@ -153,7 +153,7 @@ private function zip($file, $originalName) $zipFile = join(DIRECTORY_SEPARATOR, [$folder, "$uuid.zip"]); $zip = new \ZipArchive(); - $res = $zip->open($zipFile, ZipArchive::CREATE); + $res = $zip->open($zipFile, \ZipArchive::CREATE); if (true === $res) { $zip->addFile($outfile, "$originalName"); $zip->close();