Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
closes #112
Browse files Browse the repository at this point in the history
  • Loading branch information
ocruze committed Nov 29, 2022
1 parent f4d3bfd commit abdb0f1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Listener/UploadListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Oneup\UploaderBundle\Event\PostUploadEvent;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\File\File;
use ZipArchive;

/**
* @author pprevautel
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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']) {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit abdb0f1

Please sign in to comment.