From ab6b53eabe7ccf713d7e516d310afdeb2afb1e50 Mon Sep 17 00:00:00 2001 From: Gosowong <1329847115@qq.com> Date: Thu, 8 Jun 2023 10:32:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=8D=8E=E4=B8=BA?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=A1=B6=E5=92=8C=E8=AE=BE=E7=BD=AE=E8=B7=A8?= =?UTF-8?q?=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/crmeb/services/upload/extend/obs/Client.php | 7 ++++--- crmeb/crmeb/services/upload/storage/Obs.php | 13 +++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/crmeb/crmeb/services/upload/extend/obs/Client.php b/crmeb/crmeb/services/upload/extend/obs/Client.php index 95b905af0..5cdfd7cd0 100644 --- a/crmeb/crmeb/services/upload/extend/obs/Client.php +++ b/crmeb/crmeb/services/upload/extend/obs/Client.php @@ -255,7 +255,7 @@ class Client extends BaseClient ]; $res = $this->request('https://' . $header['Host'] . '/', 'PUT', [ - 'bucket' => $bucket + 'Location' => $region ], $header); return $this->response($res); @@ -335,9 +335,10 @@ class Client extends BaseClient { $header = [ 'Host' => $this->getRequestUrl($bucket, $region), + 'content-md5' => base64_encode(md5(json_encode($data), true)) ]; - $xml = $this->xmlBuild($data, 'CORSConfiguration', ''); - $res = $this->request('https://' . $header['Host'] . '/', 'PUT', [ + $xml = $this->xmlBuild($data, 'CORSConfiguration', 'CORSRule'); + $res = $this->request('https://' . $header['Host'] . '/cors ', 'PUT', [ 'bucket' => $bucket, 'body' => $xml ], $header); diff --git a/crmeb/crmeb/services/upload/storage/Obs.php b/crmeb/crmeb/services/upload/storage/Obs.php index f88eb699b..643f53b67 100644 --- a/crmeb/crmeb/services/upload/storage/Obs.php +++ b/crmeb/crmeb/services/upload/storage/Obs.php @@ -3,6 +3,7 @@ namespace crmeb\services\upload\storage; use crmeb\exceptions\AdminException; +use crmeb\exceptions\UploadException; use crmeb\services\upload\extend\obs\Client as TyClient; use crmeb\services\upload\BaseUpload; @@ -220,12 +221,12 @@ class Obs extends BaseUpload public function setBucketCors(string $name, string $region) { try { - $res = $this->app()->PutBucketCors($name, $region, [ - 'AllowedHeaders' => ['*'], - 'AllowedMethods' => ['PUT', 'GET', 'POST', 'DELETE', 'HEAD'], - 'AllowedOrigins' => ['*'], - 'ExposeHeaders' => ['ETag', 'Content-Length', 'x-cos-request-id'], - 'MaxAgeSeconds' => 12 + $this->app()->PutBucketCors($name, $region, [ + 'AllowedHeader' => ['*'], + 'AllowedMethod' => ['PUT', 'GET', 'POST', 'DELETE', 'HEAD'], + 'AllowedOrigin' => ['*'], + 'ExposeHeader' => ['ETag', 'Content-Length', 'x-cos-request-id'], + 'MaxAgeSeconds' => 100 ]); return true; } catch (\Throwable $e) {