From beaf493cb64666e4d33459026c3904003f5abd0c Mon Sep 17 00:00:00 2001 From: themohooks <81331307+themohooks@users.noreply.github.com> Date: Wed, 9 Oct 2024 22:32:40 +0300 Subject: [PATCH] add directive cloudflare-bypass If video size larger of 90 mb, they uploads to local server --- app/Controllers/Api/Images/Upload.php | 2 +- app/Services/Upload.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/Controllers/Api/Images/Upload.php b/app/Controllers/Api/Images/Upload.php index 5337c4d..c343eaa 100644 --- a/app/Controllers/Api/Images/Upload.php +++ b/app/Controllers/Api/Images/Upload.php @@ -98,7 +98,7 @@ class Upload imagejpeg($background, $outputImagePath, 90); imagedestroy($background); imagedestroy($overlay); - + $upload = new UploadPhoto($outputImagePath, 'cdn/img/'); self::$vidpreview = $upload->getSrc(); $upload = new UploadPhoto($mp4File, 'cdn/video/'); diff --git a/app/Services/Upload.php b/app/Services/Upload.php index b316471..d4eaf49 100644 --- a/app/Services/Upload.php +++ b/app/Services/Upload.php @@ -41,6 +41,20 @@ class Upload if (strtolower (NGALLERY['root']['storage']['type']) == "s3") { + if (NGALLERY['root']['video']['upload']['cloudflare-bypass'] === true) { + if ($location === 'cdn/video') { + if (filesize($_SERVER['DOCUMENT_ROOT'].'/'.$location.$filecdn) >= 94371840) { + mkdir("{$_SERVER['DOCUMENT_ROOT']}/uploads/{$location}", 0777, true); + move_uploaded_file ($tmpname, "{$_SERVER['DOCUMENT_ROOT']}/uploads/{$folder}"); + + $this->type = $type; + $this->src = "/uploads/{$folder}"; + $this->size = self::human_filesize(filesize($tmpname)); + $this->name = $name; + return; + } + } + } $s3 = new \Aws\S3\S3Client([ 'region' => NGALLERY['root']['storage']['s3']['credentials']['region'], 'version' => NGALLERY['root']['storage']['s3']['credentials']['version'],