fix: 修改华为创建桶和设置跨域

This commit is contained in:
Gosowong 2023-06-08 10:32:47 +08:00
parent 3d7b8a0a95
commit ab6b53eabe
2 changed files with 11 additions and 9 deletions

View File

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

View File

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