From 340e8c356b4bb95a99094785856583ec4fa20680 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Wed, 20 Jan 2021 20:12:08 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=E6=8D=95=E8=8E=B7=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E4=BB=A5Json=E6=96=B9=E5=BC=8F=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchUpload.php | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/extend/catcher/CatchUpload.php b/extend/catcher/CatchUpload.php index a195267..ca4bc16 100644 --- a/extend/catcher/CatchUpload.php +++ b/extend/catcher/CatchUpload.php @@ -63,25 +63,30 @@ class CatchUpload */ public function upload(UploadedFile $file): string { - $this->initUploadConfig(); + try { + $this->initUploadConfig(); - $path = Filesystem::disk($this->getDriver())->putFile($this->getPath(), $file); + $path = Filesystem::disk($this->getDriver())->putFile($this->getPath(), $file); - if ($path) { + if ($path) { - $url = self::getCloudDomain($this->getDriver()) . '/' . $this->getLocalPath($path); + $url = self::getCloudDomain($this->getDriver()) . '/' . $this->getLocalPath($path); - event('attachment', [ - 'path' => $path, - 'url' => $url, - 'driver' => $this->getDriver(), - 'file' => $file, - ]); + event('attachment', [ + 'path' => $path, + 'url' => $url, + 'driver' => $this->getDriver(), + 'file' => $file, + ]); - return $url; + return $url; + } + + throw new FailedException('Upload Failed, Try Again!'); + + } catch (\Exception $exception) { + throw new FailedException($exception->getMessage()); } - - throw new FailedException('Upload Failed, Try Again!'); } /**