diff --git a/extend/catcher/CatchUpload.php b/extend/catcher/CatchUpload.php index dab98b1..0693c24 100644 --- a/extend/catcher/CatchUpload.php +++ b/extend/catcher/CatchUpload.php @@ -61,7 +61,7 @@ class CatchUpload $path = Filesystem::disk($this->getDriver())->putFile($this->getPath(), $file); if ($path) { - $url = Utils::getCloudDomain($this->getDriver()) . $path; + $url = self::getCloudDomain($this->getDriver()) . $path; Attachments::create(array_merge([ 'path' => $path, @@ -261,4 +261,28 @@ class CatchUpload ], 'filesystem'); } } + + /** + * 获取云存储的域名 + * + * @time 2020年01月25日 + * @param $driver + * @return string + */ + public static function getCloudDomain($driver): ?string + { + $driver = \config('filesystem.disks.' . $driver); + + switch ($driver['type']) { + case CatchUpload::QIQNIU: + case CatchUpload::LOCAL: + return $driver['domain']; + case CatchUpload::OSS: + return $driver['end_point']; + case CatchUpload::QCLOUD: + return $driver['cdn']; + default: + throw new FailedException(sprintf('Driver [%s] Not Supported.', $driver)); + } + } } diff --git a/extend/catcher/Utils.php b/extend/catcher/Utils.php index fb20b7f..eb37ea2 100644 --- a/extend/catcher/Utils.php +++ b/extend/catcher/Utils.php @@ -1,8 +1,6 @@