diff --git a/README.md b/README.md index f433030..6036698 100644 --- a/README.md +++ b/README.md @@ -71,4 +71,4 @@ The HANA PDF is a open source Laravel Project that has licensed under the [MIT l --- -## HANA-CI Build Project 2016 - 2024 +## HANA-CI Build Project 2016 - 2025 diff --git a/app/Http/Controllers/Api/File/fileController.php b/app/Http/Controllers/Api/File/fileController.php index 359c104..24cdaab 100644 --- a/app/Http/Controllers/Api/File/fileController.php +++ b/app/Http/Controllers/Api/File/fileController.php @@ -85,7 +85,7 @@ public function upload(Request $request) { 201, 'File uploaded successfully !', Storage::disk('minio')->exists($pdfUpload_Location.'/'.$pdfFileName), - null + null, ); } else { return $this->returnFileMesage( @@ -103,7 +103,6 @@ public function upload(Request $request) { $e->getMessage() ); } - } else { return $this->returnFileMesage( 400, diff --git a/app/Http/Controllers/Api/File/thumbnailController.php b/app/Http/Controllers/Api/File/thumbnailController.php index b476473..ccce664 100644 --- a/app/Http/Controllers/Api/File/thumbnailController.php +++ b/app/Http/Controllers/Api/File/thumbnailController.php @@ -39,15 +39,24 @@ public function getThumbnail(Request $request) $pdfUpload_Location = env('PDF_UPLOAD'); $pdfPool_Location = env('PDF_POOL'); $currentFileName = basename($files); - $pdfFileName = str_replace(' ', '_', $currentFileName); - $pdfRealExtension = pathinfo($pdfFileName, PATHINFO_EXTENSION); - $newFilePath = Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$pdfFileName); - $thumbnailFilePath = Storage::disk('local')->path('public/'.$pdfThumbnail_Location.'/'.$pdfFileName.'.png'); + $trimPhase1 = str_replace(' ', '_', $currentFileName); + $newFileNameWithoutExtension = str_replace('.', '_', $trimPhase1); + $pdfRealExtension = pathinfo($currentFileName, PATHINFO_EXTENSION); + $pdfRealName = pathinfo($trimPhase1, PATHINFO_FILENAME); + $newFormattedFilename = str_replace('_'.$pdfRealExtension, '', $newFileNameWithoutExtension); + $minioUpload = Storage::disk('minio')->get($pdfUpload_Location.'/'.$trimPhase1); + if (Storage::disk('local')->exists('public/'.$pdfUpload_Location.'/'.$newFormattedFilename.'.'.$pdfRealExtension)) { + Storage::disk('local')->delete('public/'.$pdfUpload_Location.'/'.$newFormattedFilename.'.'.$pdfRealExtension); + } + file_put_contents(Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$newFormattedFilename.'.'.$pdfRealExtension), $minioUpload); + $newFilePath = Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$newFormattedFilename.'.'.$pdfRealExtension); + $thumbnailFilePath = Storage::disk('local')->path('public/'.$pdfThumbnail_Location.'/'.$pdfRealName.'.png'); try { + ini_set("pcre.backtrack_limit", "5000000"); Settings::setPdfRendererPath(base_path('vendor/mpdf/mpdf')); Settings::setPdfRendererName('MPDF'); - $pdfPath = Storage::disk('local')->path('public/'.$pdfPool_Location.'/'.$pdfFileName); + $pdfPath = Storage::disk('local')->path('public/'.$pdfPool_Location.'/'.$newFormattedFilename.'.'.$pdfRealExtension); if ($pdfRealExtension == 'docx' || $pdfRealExtension == 'doc') { $phpWord = WordIOFactory::load($newFilePath); $phpWord->save($pdfPath, 'PDF'); @@ -60,7 +69,7 @@ public function getThumbnail(Request $request) return $this->returnFileMesage( 400, 'Failed to generate thumbnail !', - $pdfFileName, + $pdfRealName, 'Invalid or unsupported file extension: '.$pdfRealExtension ); } @@ -69,18 +78,45 @@ public function getThumbnail(Request $request) ->format(\Spatie\PdfToImage\Enums\OutputFormat::Png) ->quality(90) ->save($thumbnailFilePath); - return $this->returnFileMesage( - 201, - 'Thumbnail generated !', - Storage::disk('local')->url(env('PDF_IMG_POOL').'/'.$pdfFileName.'.png'), - $pdfFileName - ); + if (Storage::disk('local')->exists('public/'.$pdfThumbnail_Location.'/'.$pdfRealName.'.png')) { + Storage::disk('minio')->put($pdfThumbnail_Location.'/'.$pdfRealName.'.png', file_get_contents($thumbnailFilePath)); + Storage::disk('local')->delete('public/'.$pdfThumbnail_Location.'/'.$pdfRealName.'.png'); + Storage::disk('local')->delete('public/'.$pdfPool_Location.'/'.$newFormattedFilename.'.'.$pdfRealExtension); + try { + if (Storage::disk('minio')->exists($pdfThumbnail_Location.'/'.$pdfRealName.'.png')) { + return $this->returnFileMesage( + 201, + 'Thumbnail generated !', + Storage::disk('minio')->temporaryUrl( + env('PDF_IMG_POOL').'/'.$pdfRealName.'.png', + now()->addMinutes(5) + ), + Storage::disk('local')->url(env('PDF_IMG_POOL').'/'.$pdfRealName.'.png'), + null, + ); + } else { + return $this->returnFileMesage( + 400, + 'Failed to upload file !', + $pdfFileName, + $pdfFileName.' could not be found in the object storage' + ); + } + } catch (\Exception $e) { + return $this->returnFileMesage( + 400, + 'Failed to upload thumbnail to object storage !', + $pdfFileName, + $e->getMessage() + ); + } + } } catch (Exception $e) { return $this->returnFileMesage( 500, 'Failed to generate thumbnail !', - $pdfFileName, - $pdfFileName.' could not generate thumbnail with error: '.$e->getMessage() + $pdfRealName, + 'Could not generate thumbnail with error: '.$e->getMessage() ); } } diff --git a/app/Http/Controllers/Api/Misc/versionController.php b/app/Http/Controllers/Api/Misc/versionController.php index 25fa2aa..9522e4f 100644 --- a/app/Http/Controllers/Api/Misc/versionController.php +++ b/app/Http/Controllers/Api/Misc/versionController.php @@ -42,7 +42,7 @@ public function versioningCheck(Request $request) { $appServicesReferrerFE = $request->post('appServicesReferrer'); $appMajorVersionBE = 3; $appMinorVersionBE = 6; - $appPatchVersionBE = 5; + $appPatchVersionBE = 7; $appVersioningBE = null; $appVersioningFE = null; $appServicesReferrerBE = "BE"; diff --git a/composer.lock b/composer.lock index 28d0943..b5f8cb5 100644 --- a/composer.lock +++ b/composer.lock @@ -154,16 +154,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.336.5", + "version": "3.336.8", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "4ba9b84343bf9b6a4de892a9dd0350e2331845b1" + "reference": "933da0d1b9b1ac9b37d5e32e127d4581b1aabaf6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/4ba9b84343bf9b6a4de892a9dd0350e2331845b1", - "reference": "4ba9b84343bf9b6a4de892a9dd0350e2331845b1", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/933da0d1b9b1ac9b37d5e32e127d4581b1aabaf6", + "reference": "933da0d1b9b1ac9b37d5e32e127d4581b1aabaf6", "shasum": "" }, "require": { @@ -246,9 +246,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.336.5" + "source": "https://github.com/aws/aws-sdk-php/tree/3.336.8" }, - "time": "2024-12-27T19:06:57+00:00" + "time": "2025-01-03T19:06:11+00:00" }, { "name": "brick/math", @@ -1555,16 +1555,16 @@ }, { "name": "laravel/framework", - "version": "v11.36.1", + "version": "v11.37.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "df06f5163f4550641fdf349ebc04916a61135a64" + "reference": "6cb103d2024b087eae207654b3f4b26646119ba5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/df06f5163f4550641fdf349ebc04916a61135a64", - "reference": "df06f5163f4550641fdf349ebc04916a61135a64", + "url": "https://api.github.com/repos/laravel/framework/zipball/6cb103d2024b087eae207654b3f4b26646119ba5", + "reference": "6cb103d2024b087eae207654b3f4b26646119ba5", "shasum": "" }, "require": { @@ -1614,7 +1614,6 @@ "voku/portable-ascii": "^2.0.2" }, "conflict": { - "mockery/mockery": "1.6.8", "tightenco/collect": "<5.5.33" }, "provide": { @@ -1766,7 +1765,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-12-17T22:32:08+00:00" + "time": "2025-01-02T20:10:21+00:00" }, { "name": "laravel/prompts", @@ -2093,16 +2092,16 @@ }, { "name": "league/commonmark", - "version": "2.6.0", + "version": "2.6.1", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "d150f911e0079e90ae3c106734c93137c184f932" + "reference": "d990688c91cedfb69753ffc2512727ec646df2ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/d150f911e0079e90ae3c106734c93137c184f932", - "reference": "d150f911e0079e90ae3c106734c93137c184f932", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/d990688c91cedfb69753ffc2512727ec646df2ad", + "reference": "d990688c91cedfb69753ffc2512727ec646df2ad", "shasum": "" }, "require": { @@ -2196,7 +2195,7 @@ "type": "tidelift" } ], - "time": "2024-12-07T15:34:16+00:00" + "time": "2024-12-29T14:10:59+00:00" }, { "name": "league/config", @@ -3715,16 +3714,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.3.1", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" + "reference": "447a020a1f875a434d62f2a401f53b82a396e494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", - "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494", + "reference": "447a020a1f875a434d62f2a401f53b82a396e494", "shasum": "" }, "require": { @@ -3767,9 +3766,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0" }, - "time": "2024-10-08T18:51:32+00:00" + "time": "2024-12-30T11:07:19+00:00" }, { "name": "nunomaduro/termwind", @@ -4018,16 +4017,16 @@ }, { "name": "php-open-source-saver/jwt-auth", - "version": "2.7.2", + "version": "2.7.3", "source": { "type": "git", "url": "https://github.com/PHP-Open-Source-Saver/jwt-auth.git", - "reference": "460edf53c4529d16ffa81c264e0ee39b0041bacb" + "reference": "5dec649af5f5d666d686df084b9e8bdd27102f0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-Open-Source-Saver/jwt-auth/zipball/460edf53c4529d16ffa81c264e0ee39b0041bacb", - "reference": "460edf53c4529d16ffa81c264e0ee39b0041bacb", + "url": "https://api.github.com/repos/PHP-Open-Source-Saver/jwt-auth/zipball/5dec649af5f5d666d686df084b9e8bdd27102f0b", + "reference": "5dec649af5f5d666d686df084b9e8bdd27102f0b", "shasum": "" }, "require": { @@ -4047,7 +4046,7 @@ "illuminate/routing": "^10|^11", "mockery/mockery": "^1.4.4", "orchestra/testbench": "^8|^9", - "phpstan/phpstan": "^1", + "phpstan/phpstan": "^2", "phpunit/phpunit": "^10.5|^11" }, "type": "library", @@ -4105,7 +4104,7 @@ "issues": "https://github.com/PHP-Open-Source-Saver/jwt-auth/issues", "source": "https://github.com/PHP-Open-Source-Saver/jwt-auth" }, - "time": "2024-09-27T17:59:55+00:00" + "time": "2024-12-30T17:41:54+00:00" }, { "name": "phpoffice/common", @@ -6134,16 +6133,16 @@ }, { "name": "symfony/finder", - "version": "v7.2.0", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "6de263e5868b9a137602dd1e33e4d48bfae99c49" + "reference": "87a71856f2f56e4100373e92529eed3171695cfb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/6de263e5868b9a137602dd1e33e4d48bfae99c49", - "reference": "6de263e5868b9a137602dd1e33e4d48bfae99c49", + "url": "https://api.github.com/repos/symfony/finder/zipball/87a71856f2f56e4100373e92529eed3171695cfb", + "reference": "87a71856f2f56e4100373e92529eed3171695cfb", "shasum": "" }, "require": { @@ -6178,7 +6177,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.2.0" + "source": "https://github.com/symfony/finder/tree/v7.2.2" }, "funding": [ { @@ -6194,20 +6193,20 @@ "type": "tidelift" } ], - "time": "2024-10-23T06:56:12+00:00" + "time": "2024-12-30T19:00:17+00:00" }, { "name": "symfony/http-foundation", - "version": "v7.2.0", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "e88a66c3997859532bc2ddd6dd8f35aba2711744" + "reference": "62d1a43796ca3fea3f83a8470dfe63a4af3bc588" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e88a66c3997859532bc2ddd6dd8f35aba2711744", - "reference": "e88a66c3997859532bc2ddd6dd8f35aba2711744", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/62d1a43796ca3fea3f83a8470dfe63a4af3bc588", + "reference": "62d1a43796ca3fea3f83a8470dfe63a4af3bc588", "shasum": "" }, "require": { @@ -6256,7 +6255,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v7.2.0" + "source": "https://github.com/symfony/http-foundation/tree/v7.2.2" }, "funding": [ { @@ -6272,20 +6271,20 @@ "type": "tidelift" } ], - "time": "2024-11-13T18:58:46+00:00" + "time": "2024-12-30T19:00:17+00:00" }, { "name": "symfony/http-kernel", - "version": "v7.2.1", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "d8ae58eecae44c8e66833e76cc50a4ad3c002d97" + "reference": "3c432966bd8c7ec7429663105f5a02d7e75b4306" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/d8ae58eecae44c8e66833e76cc50a4ad3c002d97", - "reference": "d8ae58eecae44c8e66833e76cc50a4ad3c002d97", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/3c432966bd8c7ec7429663105f5a02d7e75b4306", + "reference": "3c432966bd8c7ec7429663105f5a02d7e75b4306", "shasum": "" }, "require": { @@ -6370,7 +6369,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v7.2.1" + "source": "https://github.com/symfony/http-kernel/tree/v7.2.2" }, "funding": [ { @@ -6386,7 +6385,7 @@ "type": "tidelift" } ], - "time": "2024-12-11T12:09:10+00:00" + "time": "2024-12-31T14:59:40+00:00" }, { "name": "symfony/mailer", @@ -7570,16 +7569,16 @@ }, { "name": "symfony/translation", - "version": "v7.2.0", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "dc89e16b44048ceecc879054e5b7f38326ab6cc5" + "reference": "e2674a30132b7cc4d74540d6c2573aa363f05923" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/dc89e16b44048ceecc879054e5b7f38326ab6cc5", - "reference": "dc89e16b44048ceecc879054e5b7f38326ab6cc5", + "url": "https://api.github.com/repos/symfony/translation/zipball/e2674a30132b7cc4d74540d6c2573aa363f05923", + "reference": "e2674a30132b7cc4d74540d6c2573aa363f05923", "shasum": "" }, "require": { @@ -7645,7 +7644,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v7.2.0" + "source": "https://github.com/symfony/translation/tree/v7.2.2" }, "funding": [ { @@ -7661,7 +7660,7 @@ "type": "tidelift" } ], - "time": "2024-11-12T20:47:56+00:00" + "time": "2024-12-07T08:18:10+00:00" }, { "name": "symfony/translation-contracts", @@ -8358,16 +8357,16 @@ }, { "name": "laravel/pint", - "version": "v1.18.3", + "version": "v1.19.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "cef51821608239040ab841ad6e1c6ae502ae3026" + "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/cef51821608239040ab841ad6e1c6ae502ae3026", - "reference": "cef51821608239040ab841ad6e1c6ae502ae3026", + "url": "https://api.github.com/repos/laravel/pint/zipball/8169513746e1bac70c85d6ea1524d9225d4886f0", + "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0", "shasum": "" }, "require": { @@ -8378,10 +8377,10 @@ "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.65.0", - "illuminate/view": "^10.48.24", - "larastan/larastan": "^2.9.11", - "laravel-zero/framework": "^10.4.0", + "friendsofphp/php-cs-fixer": "^3.66.0", + "illuminate/view": "^10.48.25", + "larastan/larastan": "^2.9.12", + "laravel-zero/framework": "^10.48.25", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^1.17.0", "pestphp/pest": "^2.36.0" @@ -8420,7 +8419,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-11-26T15:34:00+00:00" + "time": "2024-12-30T16:20:10+00:00" }, { "name": "laravel/sail",