(.*?)<\/Code>(.*?)<\/Message>(.*?)<\/Resource>(.*?)<\/RequestId>/';
-
- preg_match($pattern, $errorXml, $matches);
-
- $error = [
- 'statusCode' => $matches[1],
- 'Code' => $matches[2],
- 'Message' => $matches[3],
- 'Resource' => $matches[4],
- 'RequestId' => $matches[5]
- ];
-
- return $error;
-
- }
}
diff --git a/crmeb/crmeb/services/upload/storage/Obs.php b/crmeb/crmeb/services/upload/storage/Obs.php
index 8d1bfcf53..860bc4756 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']['Bucket'] ?? [];
+ return $res['Buckets'] ?? [];
} catch (\Throwable $e) {
return [];
}
@@ -169,7 +169,7 @@ class Obs extends BaseUpload
$data = [
'Statement' => [
'Sid' => '公共读' . $name,
- 'Effect' => 'Allow1',
+ 'Effect' => 'Allow',
'Principal' => [
'ID' => ['*']
],
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 34/48] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E4=BA=91?=
=?UTF-8?q?=E5=82=A8=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 [];
}
From 39368b2e3d4bbbb6a0b5dde1e5fd16c17ddb5ecc Mon Sep 17 00:00:00 2001
From: Gosowong <1329847115@qq.com>
Date: Thu, 8 Jun 2023 17:38:08 +0800
Subject: [PATCH 35/48] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=A4=A9?=
=?UTF-8?q?=E7=BF=BC=E4=BA=91=E4=BA=91=E5=82=A8=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crmeb/crmeb/services/upload/storage/Obs.php | 7 +-
crmeb/crmeb/services/upload/storage/Tyoss.php | 222 +++++++++++++-----
2 files changed, 165 insertions(+), 64 deletions(-)
diff --git a/crmeb/crmeb/services/upload/storage/Obs.php b/crmeb/crmeb/services/upload/storage/Obs.php
index fc0428a9b..c5a9910f5 100644
--- a/crmeb/crmeb/services/upload/storage/Obs.php
+++ b/crmeb/crmeb/services/upload/storage/Obs.php
@@ -136,17 +136,16 @@ class Obs extends BaseUpload
$this->handle = new TyClient([
'accessKey' => $this->accessKey,
'secretKey' => $this->secretKey,
- 'region' => $this->storageRegion ?: 'oos-hazz',
+ 'region' => $this->storageRegion ?: 'cn-north-1',
'bucket' => $this->storageName,
'uploadUrl' => $this->uploadUrl
]);
return $this->handle;
}
- public function listbuckets(string $region, bool $line = false, bool $shared = false)
+ public function listbuckets(string $region = null, bool $line = false, bool $shared = false)
{
try {
- $this->storageRegion = $region;
$res = $this->app()->listBuckets();
return $res['Buckets']['Bucket'] ?? [];
} catch (\Throwable $e) {
@@ -205,7 +204,7 @@ class Obs extends BaseUpload
try {
$res = $this->app()->GetBucketDomain($name, $region);
if ($res) {
- $domainRules = $res->toArray()['ListBucketCustomDomainsResult '];
+ $domainRules = $res->toArray()['ListBucketCustomDomainsResult'];
return array_column($domainRules, 'DomainName');
} else {
return [];
diff --git a/crmeb/crmeb/services/upload/storage/Tyoss.php b/crmeb/crmeb/services/upload/storage/Tyoss.php
index 74175be2e..61e9b862c 100644
--- a/crmeb/crmeb/services/upload/storage/Tyoss.php
+++ b/crmeb/crmeb/services/upload/storage/Tyoss.php
@@ -5,6 +5,7 @@ namespace crmeb\services\upload\storage;
use crmeb\exceptions\AdminException;
use crmeb\services\upload\extend\obs\Client as TyClient;
use crmeb\services\upload\BaseUpload;
+use GuzzleHttp\Psr7\Utils;
class Tyoss extends BaseUpload
{
@@ -69,7 +70,8 @@ class Tyoss extends BaseUpload
}
$key = $this->saveFileName($fileHandle->getRealPath(), $fileHandle->getOriginalExtension());
- $body = $fileHandle->getRealPath();
+ $body = fopen($fileHandle->getRealPath(), 'rb');
+ $body = (string)Utils::streamFor($body);
} else {
$key = $file;
$body = $fileContent;
@@ -77,7 +79,7 @@ class Tyoss extends BaseUpload
$key = $this->getUploadPath($key);
try {
- $uploadInfo = $this->app()->putObject($key, $body);
+ $uploadInfo = $this->app()->putObject($key, $body, 'application/octet-stream');
$this->fileInfo->uploadInfo = $uploadInfo;
$this->fileInfo->realName = $fileHandle->getOriginalName();
$this->fileInfo->filePath = ($this->cdn ?: $this->uploadUrl) . '/' . $key;
@@ -133,7 +135,7 @@ class Tyoss extends BaseUpload
$this->handle = new TyClient([
'accessKey' => $this->accessKey,
'secretKey' => $this->secretKey,
- 'region' => $this->storageRegion ?: 'oos-hazz',
+ 'region' => $this->storageRegion ?: 'cn-qhxn1',
'bucket' => $this->storageName,
'uploadUrl' => $this->uploadUrl,
'type' => 'ty'
@@ -141,10 +143,9 @@ class Tyoss extends BaseUpload
return $this->handle;
}
- public function listbuckets(string $region, bool $line = false, bool $shared = false)
+ public function listbuckets(string $region = null, bool $line = false, bool $shared = false)
{
try {
- $this->storageRegion = $region;
$res = $this->app()->listBuckets();
return $res['Buckets']['Bucket'] ?? [];
} catch (\Throwable $e) {
@@ -163,79 +164,156 @@ class Tyoss extends BaseUpload
$app = $this->app();
//创建桶
try {
- $res = $app->createBucket($name, $region, $acl);
+ $app->createBucket($name, $region, $acl);
+ $data = [
+ 'Statement' => [
+ 'Sid' => '公共读' . $name,
+ 'Effect' => 'Allow',
+ 'Principal' => [
+ 'ID' => ['*']
+ ],
+ 'Action' => ['HeadBucket', 'GetBucketLocation', 'ListBucketVersions', 'GetObject', 'RestoreObject', 'GetObjectVersion'],
+ 'Resource' => [$name, $name . '/*']
+ ]
+ ];
+
+ $app->putPolicy($name, $region, $data);
} catch (\Throwable $e) {
return $this->setError('COS:' . $e->getMessage());
}
- return $res;
+ return true;
}
public function getRegion()
{
return [
[
- 'value' => 'oos-hazz',
+ 'value' => 'cn-gz1',
+ 'label' => '贵州'
+ ],
+ [
+ 'value' => 'cn-fz1',
+ 'label' => '福州'
+ ],
+ [
+ 'value' => 'cn-hz1',
+ 'label' => '杭州'
+ ],
+ [
+ 'value' => 'cn-sz1',
+ 'label' => '深圳'
+ ],
+ [
+ 'value' => 'cn-gdgz1',
+ 'label' => '广州'
+ ],
+ [
+ 'value' => 'cn-jssz1',
+ 'label' => '苏州'
+ ],
+ [
+ 'value' => 'cn-sh1',
+ 'label' => '上海'
+ ],
+ [
+ 'value' => 'cn-ahwh1',
+ 'label' => '芜湖'
+ ],
+ [
+ 'value' => 'cn-bj1',
+ 'label' => '北京'
+ ],
+ [
+ 'value' => 'cn-sccd1',
+ 'label' => '成都'
+ ],
+ [
+ 'value' => 'cn-hazz1',
'label' => '郑州'
],
[
- 'value' => 'oos-lnsy',
- 'label' => '沈阳'
+ 'value' => 'cn-hncs1',
+ 'label' => '长沙'
],
[
- 'value' => 'oos-sccd',
- 'label' => '四川成都'
+ 'value' => 'cn-gxnn1',
+ 'label' => '南宁'
],
[
- 'value' => 'oos-xjwlmq',
- 'label' => '乌鲁木齐'
+ 'value' => 'cn-jxnc1',
+ 'label' => '南昌'
],
[
- 'value' => 'oos-xjwlmq',
- 'label' => '乌鲁木齐'
- ],
- [
- 'value' => 'oos-gslz',
- 'label' => '甘肃兰州'
- ],
- [
- 'value' => 'oos-sdqd',
- 'label' => '山东青岛'
- ],
- [
- 'value' => 'oos-gzgy',
- 'label' => '贵州贵阳'
- ],
- [
- 'value' => 'oos-hbwh',
- 'label' => '湖北武汉'
- ],
- [
- 'value' => 'oos-xzls',
- 'label' => '西藏拉萨'
- ],
- [
- 'value' => 'oos-hbwh',
- 'label' => '湖北武汉'
- ],
- [
- 'value' => 'oos-ahwh',
- 'label' => '安徽芜湖'
- ],
- [
- 'value' => 'oos-gdsz',
- 'label' => '广东深圳'
- ],
- [
- 'value' => 'oos-jssz',
- 'label' => '江苏苏州'
- ],
- [
- 'value' => 'oos-sh2',
- 'label' => '上海2'
+ 'value' => 'cn-sdqd1',
+ 'label' => '青岛'
],
[
'value' => 'cn-snxy1',
- 'label' => '西安2'
+ 'label' => '咸阳'
+ ],
+ [
+ 'value' => 'cn-xjcj1',
+ 'label' => '新疆'
+ ],
+ [
+ 'value' => 'cn-ynkm1',
+ 'label' => '昆明'
+ ],
+ [
+ 'value' => 'cn-hihk1',
+ 'label' => '海口'
+ ],
+ [
+ 'value' => 'cn-hbwh1',
+ 'label' => '武汉'
+ ],
+ [
+ 'value' => 'cn-cq1',
+ 'label' => '重庆'
+ ],
+ [
+ 'value' => 'cn-qhxn1',
+ 'label' => '西宁'
+ ],
+ [
+ 'value' => 'cn-gslz1',
+ 'label' => '兰州'
+ ],
+ [
+ 'value' => 'cn-nxyc1',
+ 'label' => '银川'
+ ],
+ [
+ 'value' => 'cn-sxty1',
+ 'label' => '太原'
+ ],
+ [
+ 'value' => 'cn-hesjz1',
+ 'label' => '石家庄'
+ ],
+ [
+ 'value' => 'cn-tj1',
+ 'label' => '天津'
+ ],
+ [
+ 'value' => 'cn-jlcc1',
+ 'label' => '长春'
+ ],
+ [
+ 'value' => 'cn-hlhrb1',
+ 'label' => '哈尔滨'
+ ],
+ [
+ 'value' => 'cn-nmhh1',
+ 'label' => '内蒙古'
+ ],
+ [
+ 'value' => 'cn-lnsy1',
+ 'label' => '沈阳'
+ ],
+ [
+ 'value' => 'cn-north1',
+ 'label' => '华北'
]
];
}
@@ -250,20 +328,44 @@ class Tyoss extends BaseUpload
}
}
+ public function getDomian($name, $region)
+ {
+ try {
+ $res = $this->app()->GetBucketDomain($name, $region);
+ if ($res) {
+ $domainRules = $res->toArray()['ListBucketCustomDomainsResult'];
+ return array_column($domainRules, 'DomainName');
+ } else {
+ return [];
+ }
+
+ } catch (\Throwable $e) {
+ }
+ return [];
+ }
+
public function bindDomian(string $name, string $domain, string $region = null)
{
- // TODO: Implement bindDomian() method.
+ $parseDomin = parse_url($domain);
+ try {
+ $this->app()->putBucketDomain($name, $region, [
+ 'domainname' => $parseDomin['host'],
+ ]);
+ return true;
+ } catch (\Throwable $e) {
+ return $this->setError($e->getMessage());
+ }
}
public function setBucketCors(string $name, string $region)
{
try {
- $res = $this->app()->PutBucketCors($name, $region, [
+ $this->app()->PutBucketCors($name, $region, [
'AllowedHeaders' => ['*'],
'AllowedMethods' => ['PUT', 'GET', 'POST', 'DELETE', 'HEAD'],
'AllowedOrigins' => ['*'],
'ExposeHeaders' => ['ETag', 'Content-Length', 'x-cos-request-id'],
- 'MaxAgeSeconds' => 12
+ 'MaxAgeSeconds' => 100
]);
return true;
} catch (\Throwable $e) {
From 52052ad3a18f1365b6feeb47b4673249bf368aad Mon Sep 17 00:00:00 2001
From: From-wh
Date: Thu, 8 Jun 2023 18:15:18 +0800
Subject: [PATCH 36/48] =?UTF-8?q?feat:=20=E5=B0=8F=E7=A8=8B=E5=BA=8F?=
=?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=93=BE=E6=8E=A5=E6=94=AF=E6=8C=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/components/linkaddress/index.vue | 57 ++++++++++++-------
1 file changed, 38 insertions(+), 19 deletions(-)
diff --git a/template/admin/src/components/linkaddress/index.vue b/template/admin/src/components/linkaddress/index.vue
index 79a3532a3..540dcf459 100644
--- a/template/admin/src/components/linkaddress/index.vue
+++ b/template/admin/src/components/linkaddress/index.vue
@@ -250,31 +250,38 @@
-
-
-
-
-
-
-
-
-
-
-
腾讯云cos开通方法:点击查看
++ 京东云cos开通方法:点击查看 +
++ 华为云cos开通方法:点击查看 +
++ 天翼云cos开通方法:点击查看 +
第一步: 添加【存储空间】(空间名称不能重复)
第二步: 开启【使用状态】
@@ -52,6 +61,9 @@