From 1e6ccb1c7c188c0f1a555a1582c3bed68ef6cd3a Mon Sep 17 00:00:00 2001 From: Gosowong <1329847115@qq.com> Date: Thu, 8 Jun 2023 17:11:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E4=BA=91=E5=82=A8?= =?UTF-8?q?=E5=AD=98=E5=90=8C=E6=AD=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/config/SystemStorageServices.php | 7 +------ .../services/upload/extend/obs/Client.php | 21 +++++++++++-------- crmeb/crmeb/services/upload/storage/Obs.php | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/crmeb/app/services/system/config/SystemStorageServices.php b/crmeb/app/services/system/config/SystemStorageServices.php index 6fff59dbe..85d0c3f7e 100644 --- a/crmeb/app/services/system/config/SystemStorageServices.php +++ b/crmeb/app/services/system/config/SystemStorageServices.php @@ -373,11 +373,6 @@ class SystemStorageServices extends BaseServices case 7:// cos 天翼云 $upload = UploadService::init($type); $list = $upload->listbuckets(); - if (!empty($list['Name'])) { - $newList = $list; - $list = []; - $list[] = $newList; - } $config = $this->getStorageConfig($type); foreach ($list as $item) { if (!$this->dao->count(['name' => $item['Name'], 'access_key' => $config['accessKey']])) { @@ -388,7 +383,7 @@ class SystemStorageServices extends BaseServices 'region' => $item['Location'], 'acl' => 'public-read', 'status' => 0, - 'domain' => sys_config('tengxun_appid') ? $this->getDomain($type, $item['Name'], $item['Location']) : '', + 'domain' => $this->getDomain($type, $item['Name'], $item['Location']), 'is_delete' => 0, 'add_time' => strtotime($item['CreationDate']), 'update_time' => time() diff --git a/crmeb/crmeb/services/upload/extend/obs/Client.php b/crmeb/crmeb/services/upload/extend/obs/Client.php index fb3129c3b..222b04b8f 100644 --- a/crmeb/crmeb/services/upload/extend/obs/Client.php +++ b/crmeb/crmeb/services/upload/extend/obs/Client.php @@ -220,7 +220,7 @@ class Client extends BaseClient public function listBuckets() { $header = [ - 'Host' => $this->getRequestUrl($this->bucketName, $this->region), + 'Host' => $this->getRequestUrl('', $this->region), ]; $res = $this->request('https://' . $header['Host'] . '/', 'GET', [], []); return $this->response($res); @@ -413,19 +413,22 @@ class Client extends BaseClient * @param string $bucket * @param string $region * @return string - * @author 等风来 - * @email 136327134@qq.com - * @date 2023/5/18 + * + * @date 2023/06/08 + * @author yyw */ - protected function getRequestUrl(string $bucket, string $region) + protected function getRequestUrl(string $bucket = '', string $region = '') { if ($this->type == 'hw') { - return $bucket . '.obs.' . $region . '.myhuaweicloud.com'; // 华为 + $url = '.myhuaweicloud.com'; // 华为 } else { - return $bucket . '.obs.' . $region . '.ctyun.cn'; // 天翼 + $url = $region . '.ctyun.cn'; // 天翼 + } + if ($bucket) { + return $bucket . '.obs.' . $region . $url; + } else { + return 'obs.' . $region . $url; } - - } /** diff --git a/crmeb/crmeb/services/upload/storage/Obs.php b/crmeb/crmeb/services/upload/storage/Obs.php index 860bc4756..fc0428a9b 100644 --- a/crmeb/crmeb/services/upload/storage/Obs.php +++ b/crmeb/crmeb/services/upload/storage/Obs.php @@ -148,7 +148,7 @@ class Obs extends BaseUpload try { $this->storageRegion = $region; $res = $this->app()->listBuckets(); - return $res['Buckets'] ?? []; + return $res['Buckets']['Bucket'] ?? []; } catch (\Throwable $e) { return []; }