fix: 修改云储存同步问题

This commit is contained in:
Gosowong 2023-06-08 17:11:08 +08:00
parent 7e9ed57c40
commit 1e6ccb1c7c
3 changed files with 14 additions and 16 deletions

View File

@ -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()

View File

@ -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;
}
}
/**

View File

@ -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 [];
}