From 2f131368d23dca24467d1d267d3f819667a43527 Mon Sep 17 00:00:00 2001 From: Gosowong <1329847115@qq.com> Date: Wed, 7 Jun 2023 17:35:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=8D=8E=E4=B8=BA?= =?UTF-8?q?=E4=BA=91=E5=9F=9F=E5=90=8D=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/upload/extend/obs/Client.php | 12 +++++++-- crmeb/crmeb/services/upload/storage/Obs.php | 27 ++++++++----------- crmeb/crmeb/services/upload/storage/Tyoss.php | 3 ++- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/crmeb/crmeb/services/upload/extend/obs/Client.php b/crmeb/crmeb/services/upload/extend/obs/Client.php index 9f1993f37..95b905af0 100644 --- a/crmeb/crmeb/services/upload/extend/obs/Client.php +++ b/crmeb/crmeb/services/upload/extend/obs/Client.php @@ -124,6 +124,8 @@ class Client extends BaseClient */ protected $baseUrl = 'obs.cn-north-1.myhuaweicloud.com'; + protected $type = 'hw'; + /** * Client constructor. * @param array $config @@ -135,6 +137,7 @@ class Client extends BaseClient $this->bucketName = $config['bucket'] ?? ''; $this->region = $config['region'] ?? 'ap-chengdu'; $this->uploadUrl = $config['uploadUrl'] ?? ''; + $this->type = $config['type'] ?? 'hw'; } /** @@ -368,8 +371,13 @@ class Client extends BaseClient */ protected function getRequestUrl(string $bucket, string $region) { -// return $bucket . '.obs.' . $region . '.myhuaweicloud.com'; // 华为 - return $bucket . '.obs.' . $region . '.ctyun.cn'; // 天翼 + if ($this->type == 'hw') { + return $bucket . '.obs.' . $region . '.myhuaweicloud.com'; // 华为 + } else { + return $bucket . '.obs.' . $region . '.ctyun.cn'; // 天翼 + } + + } /** diff --git a/crmeb/crmeb/services/upload/storage/Obs.php b/crmeb/crmeb/services/upload/storage/Obs.php index aa0c017f1..f88eb699b 100644 --- a/crmeb/crmeb/services/upload/storage/Obs.php +++ b/crmeb/crmeb/services/upload/storage/Obs.php @@ -162,16 +162,11 @@ class Obs extends BaseUpload $app = $this->app(); //创建桶 try { - $res = $app->createBucket($name, $region, $acl); + $app->createBucket($name, $region, $acl); } catch (\Throwable $e) { - if (strstr('[curl] 6', $e->getMessage())) { - return $this->setError('COS:无效的区域!!'); - } else if (strstr('Access Denied.', $e->getMessage())) { - return $this->setError('COS:无权访问'); - } return $this->setError('COS:' . $e->getMessage()); } - return $res; + return true; } public function getRegion() @@ -193,8 +188,13 @@ class Obs extends BaseUpload { try { $res = $this->app()->GetBucketDomain($name, $region); - $domainRules = $res->toArray()['ListBucketCustomDomainsResult ']; - return array_column($domainRules, 'Name'); + if ($res) { + $domainRules = $res->toArray()['ListBucketCustomDomainsResult ']; + return array_column($domainRules, 'DomainName'); + } else { + return []; + } + } catch (\Throwable $e) { } return []; @@ -204,15 +204,10 @@ class Obs extends BaseUpload { $parseDomin = parse_url($domain); try { - $res = $this->app()->putBucketDomain($name, '', [ + $this->app()->putBucketDomain($name, '', [ 'domainname' => $parseDomin['host'], ]); - if (method_exists($res, 'toArray')) { - $res = $res->toArray(); - } - if ($res['RequestId'] ?? null) { - return true; - } + return true; } catch (\Throwable $e) { if ($message = $this->setMessage($e->getMessage())) { return $this->setError($message); diff --git a/crmeb/crmeb/services/upload/storage/Tyoss.php b/crmeb/crmeb/services/upload/storage/Tyoss.php index 4c50204fd..74175be2e 100644 --- a/crmeb/crmeb/services/upload/storage/Tyoss.php +++ b/crmeb/crmeb/services/upload/storage/Tyoss.php @@ -135,7 +135,8 @@ class Tyoss extends BaseUpload 'secretKey' => $this->secretKey, 'region' => $this->storageRegion ?: 'oos-hazz', 'bucket' => $this->storageName, - 'uploadUrl' => $this->uploadUrl + 'uploadUrl' => $this->uploadUrl, + 'type' => 'ty' ]); return $this->handle; }