فهرست منبع

fix: 修改云储存同步问题

Gosowong 2 سال پیش
والد
کامیت
1e6ccb1c7c

+ 1 - 6
crmeb/app/services/system/config/SystemStorageServices.php

@@ -373,11 +373,6 @@ class SystemStorageServices extends BaseServices
             case 7:// cos 天翼云
             case 7:// cos 天翼云
                 $upload = UploadService::init($type);
                 $upload = UploadService::init($type);
                 $list = $upload->listbuckets();
                 $list = $upload->listbuckets();
-                if (!empty($list['Name'])) {
-                    $newList = $list;
-                    $list = [];
-                    $list[] = $newList;
-                }
                 $config = $this->getStorageConfig($type);
                 $config = $this->getStorageConfig($type);
                 foreach ($list as $item) {
                 foreach ($list as $item) {
                     if (!$this->dao->count(['name' => $item['Name'], 'access_key' => $config['accessKey']])) {
                     if (!$this->dao->count(['name' => $item['Name'], 'access_key' => $config['accessKey']])) {
@@ -388,7 +383,7 @@ class SystemStorageServices extends BaseServices
                             'region' => $item['Location'],
                             'region' => $item['Location'],
                             'acl' => 'public-read',
                             'acl' => 'public-read',
                             'status' => 0,
                             '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,
                             'is_delete' => 0,
                             'add_time' => strtotime($item['CreationDate']),
                             'add_time' => strtotime($item['CreationDate']),
                             'update_time' => time()
                             'update_time' => time()

+ 12 - 9
crmeb/crmeb/services/upload/extend/obs/Client.php

@@ -220,7 +220,7 @@ class Client extends BaseClient
     public function listBuckets()
     public function listBuckets()
     {
     {
         $header = [
         $header = [
-            'Host' => $this->getRequestUrl($this->bucketName, $this->region),
+            'Host' => $this->getRequestUrl('', $this->region),
         ];
         ];
         $res = $this->request('https://' . $header['Host'] . '/', 'GET', [], []);
         $res = $this->request('https://' . $header['Host'] . '/', 'GET', [], []);
         return $this->response($res);
         return $this->response($res);
@@ -413,19 +413,22 @@ class Client extends BaseClient
      * @param string $bucket
      * @param string $bucket
      * @param string $region
      * @param string $region
      * @return string
      * @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') {
         if ($this->type == 'hw') {
-            return $bucket . '.obs.' . $region . '.myhuaweicloud.com';  // 华为
+            $url = '.myhuaweicloud.com';  // 华为
         } else {
         } else {
-            return $bucket . '.obs.' . $region . '.ctyun.cn';  // 天翼
+            $url = $region . '.ctyun.cn';  // 天翼
+        }
+        if ($bucket) {
+            return $bucket . '.obs.' . $region . $url;
+        } else {
+            return 'obs.' . $region . $url;
         }
         }
-
-
     }
     }
 
 
     /**
     /**

+ 1 - 1
crmeb/crmeb/services/upload/storage/Obs.php

@@ -148,7 +148,7 @@ class Obs extends BaseUpload
         try {
         try {
             $this->storageRegion = $region;
             $this->storageRegion = $region;
             $res = $this->app()->listBuckets();
             $res = $this->app()->listBuckets();
-            return $res['Buckets'] ?? [];
+            return $res['Buckets']['Bucket'] ?? [];
         } catch (\Throwable $e) {
         } catch (\Throwable $e) {
             return [];
             return [];
         }
         }