mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-31 15:00:52 +00:00
fix: 修改华为创建桶文件上传
This commit is contained in:
parent
3394013f74
commit
285b3ca92b
@ -166,7 +166,10 @@ class SystemStorage extends AuthController
|
||||
//设置跨域规则
|
||||
try {
|
||||
$upload = UploadService::init($info->type);
|
||||
$upload->setBucketCors($info->name, $info->region);
|
||||
$res = $upload->setBucketCors($info->name, $info->region);
|
||||
if (false === $res) {
|
||||
return app('json')->fail($upload->getError());
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
|
||||
|
||||
@ -252,10 +252,12 @@ class Client extends BaseClient
|
||||
$header = [
|
||||
'x-obs-acl' => $acl,
|
||||
'Host' => $this->getRequestUrl($bucket, $region),
|
||||
"Content-Type" => "application/xml"
|
||||
];
|
||||
|
||||
$xml = "<CreateBucketConfiguration><Location>{$region}</Location></CreateBucketConfiguration>";
|
||||
$res = $this->request('https://' . $header['Host'] . '/', 'PUT', [
|
||||
'Location' => $region
|
||||
'bucket' => $bucket,
|
||||
'body' => $xml
|
||||
], $header);
|
||||
|
||||
return $this->response($res);
|
||||
@ -333,12 +335,14 @@ class Client extends BaseClient
|
||||
*/
|
||||
public function putBucketCors(string $bucket, string $region, array $data = [])
|
||||
{
|
||||
$xml = $this->xmlBuild($data, 'CORSConfiguration', 'CORSRule');
|
||||
$header = [
|
||||
'Host' => $this->getRequestUrl($bucket, $region),
|
||||
'content-md5' => base64_encode(md5(json_encode($data), true))
|
||||
'Content-Type' => 'application/xml',
|
||||
'Content-Length' => strlen($xml),
|
||||
'Content-MD5' => base64_encode(md5($xml, true))
|
||||
];
|
||||
$xml = $this->xmlBuild($data, 'CORSConfiguration', 'CORSRule');
|
||||
$res = $this->request('https://' . $header['Host'] . '/cors ', 'PUT', [
|
||||
$res = $this->request('https://' . $header['Host'] . '/cors', 'PUT', [
|
||||
'bucket' => $bucket,
|
||||
'body' => $xml
|
||||
], $header);
|
||||
|
||||
@ -6,6 +6,7 @@ use crmeb\exceptions\AdminException;
|
||||
use crmeb\exceptions\UploadException;
|
||||
use crmeb\services\upload\extend\obs\Client as TyClient;
|
||||
use crmeb\services\upload\BaseUpload;
|
||||
use GuzzleHttp\Psr7\Utils;
|
||||
|
||||
class Obs extends BaseUpload
|
||||
{
|
||||
@ -70,7 +71,8 @@ class Obs 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;
|
||||
@ -78,7 +80,7 @@ class Obs 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;
|
||||
@ -205,17 +207,13 @@ class Obs extends BaseUpload
|
||||
{
|
||||
$parseDomin = parse_url($domain);
|
||||
try {
|
||||
$this->app()->putBucketDomain($name, '', [
|
||||
$this->app()->putBucketDomain($name, $region, [
|
||||
'domainname' => $parseDomin['host'],
|
||||
]);
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
if ($message = $this->setMessage($e->getMessage())) {
|
||||
return $this->setError($message);
|
||||
}
|
||||
return $this->setError($e->getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setBucketCors(string $name, string $region)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user