From 0b71fb7e670cbac610025ace86026471eccfd4a2 Mon Sep 17 00:00:00 2001 From: mouyong Date: Fri, 3 Jan 2025 18:33:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=97=A0=E6=B3=95=E8=AE=BF=E9=97=AE=E5=88=B0?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FileStorage/app/Utilities/FileUtility.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/FileStorage/app/Utilities/FileUtility.php b/FileStorage/app/Utilities/FileUtility.php index 4b02fcc..e8250c0 100644 --- a/FileStorage/app/Utilities/FileUtility.php +++ b/FileStorage/app/Utilities/FileUtility.php @@ -137,6 +137,13 @@ public static function getStorage(): FilesystemAdapter return Storage::disk($disk); } + public static function getImageUrl($path) + { + $httpOrigin = request()->server('HTTP_ORIGIN'); + $finalUrl = $httpOrigin . $path; + return $finalUrl; + } + public static function buildLocalTemporaryUrls() { $disk = FileUtility::initConfig(); @@ -152,7 +159,8 @@ function (string $path, DateTime $expiration, array $options) { return URL::temporarySignedRoute( 'file.download', $expiration, - array_merge($options, ['action' => 'view', 'filename' => $filename, 'extension' => $extension, 'path' => $path]) + array_merge($options, ['action' => 'view', 'filename' => $filename, 'extension' => $extension, 'path' => $path]), + true, ); } ); @@ -169,10 +177,6 @@ public static function handleFileWithAction($action, $path) /** @var FilesystemAdapter */ $storage = Storage::disk($disk); - if ($disk == 'local') { - $path = "public/$path"; - } - if (!$storage->has($path)) { return null; }