From 99b3b8ae80e514dc72dfa24407b0105ceed28bf4 Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 15 May 2018 10:11:19 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=AD=98=E5=82=A8=E6=9C=8D=E5=8A=A1,=20=E4=B8=A5?= =?UTF-8?q?=E6=A0=BC=E5=8F=82=E6=95=B0=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/service/FileService.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/extend/service/FileService.php b/extend/service/FileService.php index 889ec0849..23bb6f77c 100644 --- a/extend/service/FileService.php +++ b/extend/service/FileService.php @@ -89,7 +89,7 @@ class FileService case 'oss': return self::getBaseUriOss() . $filename; } - return false; + throw new \think\Exception('未设置存储方式,无法获取到文件对应URL地址'); } /** @@ -129,11 +129,12 @@ class FileService } return $isClient ? 'http://upload-na0.qiniup.com' : 'http://up-na0.qiniup.com'; case '华南': - default: if ($isHttps) { return $isClient ? 'https://upload-z2.qiniup.com' : 'https://up-z2.qiniup.com'; } return $isClient ? 'http://upload-z2.qiniup.com' : 'http://up-z2.qiniup.com'; + default: + throw new \think\Exception('未配置七牛云存储区域'); } } @@ -173,8 +174,10 @@ class FileService return 'https://' . sysconf('storage_qiniu_domain') . '/'; case 'http': return 'http://' . sysconf('storage_qiniu_domain') . '/'; - default: + case 'auto': return '//' . sysconf('storage_qiniu_domain') . '/'; + default: + throw new \think\Exception('未设置七牛云文件地址协议'); } } @@ -191,8 +194,10 @@ class FileService return 'https://' . sysconf('storage_oss_domain') . '/'; case 'http': return 'http://' . sysconf('storage_oss_domain') . '/'; - default: + case 'auto': return '//' . sysconf('storage_oss_domain') . '/'; + default: + throw new \think\Exception('未设置阿里云文件地址协议'); } } @@ -256,9 +261,9 @@ class FileService case 'oss': $ossClient = new OssClient(sysconf('storage_oss_keyid'), sysconf('storage_oss_secret'), self::getBaseUriOss(), true); return $ossClient->getObject(sysconf('storage_oss_bucket'), $filename); + default: + throw new \think\Exception('未配置读取文件的存储方法'); } - Log::error("通过{$storage}读取文件{$filename}的不存在!"); - return null; } /**