mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-11-03 08:20:36 +00:00
fix: 华为云添加常见桶策略接口
This commit is contained in:
parent
0b9483266b
commit
31b092c311
@ -448,7 +448,7 @@ class SystemStorageServices extends BaseServices
|
||||
$storage = $this->dao->get(['id' => $id], ['domain', 'cdn']);
|
||||
$rule = [
|
||||
FormBuilder::input('domain', '空间域名', $storage['domain']),
|
||||
FormBuilder::input('cdn', 'cdn域名', $storage['cnd']),
|
||||
FormBuilder::input('cdn', 'cdn域名', $storage['cdn']),
|
||||
];
|
||||
return create_form('修改空间域名', $rule, '/system/config/storage/domain/' . $id);
|
||||
}
|
||||
|
||||
@ -235,6 +235,30 @@ class Client extends BaseClient
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置桶的策略
|
||||
* @param string $bucket
|
||||
* @param string $region
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*
|
||||
* @date 2023/06/08
|
||||
* @author yyw
|
||||
*/
|
||||
public function putPolicy(string $bucket, string $region, array $data)
|
||||
{
|
||||
$header = [
|
||||
'Host' => $this->getRequestUrl($bucket, $region),
|
||||
"Content-Type" => "application/json"
|
||||
];
|
||||
$res = $this->request('https://' . $header['Host'] . '/?policy', 'PUT', [
|
||||
'bucket' => $bucket,
|
||||
'json' => $data
|
||||
], $header);
|
||||
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建桶
|
||||
* @param string $bucket
|
||||
@ -340,7 +364,7 @@ class Client extends BaseClient
|
||||
'Content-Length' => strlen($xml),
|
||||
'Content-MD5' => base64_encode(md5($xml, true))
|
||||
];
|
||||
$res = $this->request('https://' . $header['Host'] . '/cors', 'PUT', [
|
||||
$res = $this->request('https://' . $header['Host'] . '/?cors', 'PUT', [
|
||||
'bucket' => $bucket,
|
||||
'body' => $xml
|
||||
], $header);
|
||||
@ -348,6 +372,27 @@ class Client extends BaseClient
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除跨域
|
||||
* @param string $bucket
|
||||
* @param string $region
|
||||
* @return mixed
|
||||
*
|
||||
* @date 2023/06/08
|
||||
* @author yyw
|
||||
*/
|
||||
public function deleteBucketCors(string $bucket, string $region)
|
||||
{
|
||||
$header = [
|
||||
'Host' => $this->getRequestUrl($bucket, $region),
|
||||
];
|
||||
$res = $this->request('https://' . $header['Host'] . '/?cors', 'DELETE', [
|
||||
'bucket' => $bucket,
|
||||
], $header);
|
||||
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $res
|
||||
* @return mixed
|
||||
|
||||
@ -166,6 +166,19 @@ class Obs extends BaseUpload
|
||||
//创建桶
|
||||
try {
|
||||
$app->createBucket($name, $region, $acl);
|
||||
$data = [
|
||||
'Statement' => [
|
||||
'Sid' => '公共读' . $name,
|
||||
'Effect' => 'Allow1',
|
||||
'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());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user