Просмотр исходного кода

fix: 修改华为云域名空间

Gosowong 2 лет назад
Родитель
Сommit
2f131368d2

+ 10 - 2
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';  // 天翼
+        }
+
+
     }
 
     /**

+ 11 - 16
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);

+ 2 - 1
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;
     }