修复华为云存储报错

This commit is contained in:
2025-05-11 10:02:08 +08:00
parent 4ff29bed97
commit 7934afeb04
4 changed files with 93 additions and 93 deletions

View File

@@ -6,7 +6,7 @@ return [
'title' => 'Access Key', 'title' => 'Access Key',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => '', 'value' => 'HPUA3H63YULC0YUCFE5J',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '请前往华为云控制台->我的凭证->访问密钥中生成', 'tip' => '请前往华为云控制台->我的凭证->访问密钥中生成',
@@ -18,7 +18,7 @@ return [
'title' => 'Secret Key', 'title' => 'Secret Key',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => '', 'value' => 'B2Obu8P3Er23EwzcoH8pPhbWBk0GOxpFrlwwRgSh',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '请前往华为云控制台->我的凭证->访问密钥中生成', 'tip' => '请前往华为云控制台->我的凭证->访问密钥中生成',
@@ -30,7 +30,7 @@ return [
'title' => '存储桶名称', 'title' => '存储桶名称',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => 'yourbucket', 'value' => 'zhongyi542',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '存储桶名称', 'tip' => '存储桶名称',
@@ -54,7 +54,7 @@ return [
'title' => '上传接口地址', 'title' => '上传接口地址',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => 'https://yourbucket.obs.cn-south-1.myhuaweicloud.com', 'value' => 'https://zhongyi542.obs.cn-south-1.myhuaweicloud.com',
'rule' => 'required;uploadurl', 'rule' => 'required;uploadurl',
'msg' => '', 'msg' => '',
'tip' => '请使用存储桶->基本信息->访问域名的值并在前面加上http://或https://', 'tip' => '请使用存储桶->基本信息->访问域名的值并在前面加上http://或https://',
@@ -66,7 +66,7 @@ return [
'title' => 'CDN地址', 'title' => 'CDN地址',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => 'https://yourbucket.obs.cn-south-1.myhuaweicloud.com', 'value' => 'https://zhongyi542.obs.cn-south-1.myhuaweicloud.com',
'rule' => 'required;cdnurl', 'rule' => 'required;cdnurl',
'msg' => '', 'msg' => '',
'tip' => '如果你的云存储有绑定自定义域名,请输入自定义域名', 'tip' => '如果你的云存储有绑定自定义域名,请输入自定义域名',
@@ -81,7 +81,7 @@ return [
'client' => '客户端直传(速度快,无备份)', 'client' => '客户端直传(速度快,无备份)',
'server' => '服务器中转(占用服务器带宽,有备份)', 'server' => '服务器中转(占用服务器带宽,有备份)',
], ],
'value' => 'server', 'value' => 'client',
'rule' => '', 'rule' => '',
'msg' => '', 'msg' => '',
'tip' => '', 'tip' => '',
@@ -96,7 +96,7 @@ return [
1 => '备份(附件管理将产生2条记录)', 1 => '备份(附件管理将产生2条记录)',
0 => '不备份', 0 => '不备份',
], ],
'value' => '1', 'value' => '0',
'rule' => '', 'rule' => '',
'msg' => '', 'msg' => '',
'tip' => '服务器中转模式下是否备份文件', 'tip' => '服务器中转模式下是否备份文件',
@@ -156,7 +156,7 @@ return [
'title' => '多文件上传', 'title' => '多文件上传',
'type' => 'bool', 'type' => 'bool',
'content' => [], 'content' => [],
'value' => '0', 'value' => '1',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '', 'tip' => '',

View File

@@ -27,51 +27,51 @@ namespace Obs\Internal\Common;
class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInterface class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInterface
{ {
protected $data; protected $data;
public function __construct(array $data = []) public function __construct(?array $data = [])
{ {
$this->data = $data; $this->data = $data;
} }
public function count() public function count(): int
{ {
return count($this->data); return count($this->data);
} }
public function getIterator() public function getIterator(): \Traversable
{ {
return new \ArrayIterator($this->data); return new \ArrayIterator($this->data);
} }
public function toArray() public function toArray()
{ {
return $this->data; return $this->data;
} }
public function clear() public function clear()
{ {
$this->data = []; $this->data = [];
return $this; return $this;
} }
public function getAll(array $keys = null) public function getAll(?array $keys = null)
{ {
return $keys ? array_intersect_key($this->data, array_flip($keys)) : $this->data; return $keys ? array_intersect_key($this->data, array_flip($keys)) : $this->data;
} }
public function get($key) public function get($key)
{ {
return isset($this->data[$key]) ? $this->data[$key] : null; return isset($this->data[$key]) ? $this->data[$key] : null;
} }
public function set($key, $value) public function set($key, $value)
{ {
$this->data[$key] = $value; $this->data[$key] = $value;
return $this; return $this;
} }
public function add($key, $value) public function add($key, $value)
{ {
if (!array_key_exists($key, $this->data)) { if (!array_key_exists($key, $this->data)) {
@@ -81,27 +81,27 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
} else { } else {
$this->data[$key] = [$this->data[$key], $value]; $this->data[$key] = [$this->data[$key], $value];
} }
return $this; return $this;
} }
public function remove($key) public function remove($key)
{ {
unset($this->data[$key]); unset($this->data[$key]);
return $this; return $this;
} }
public function getKeys() public function getKeys()
{ {
return array_keys($this->data); return array_keys($this->data);
} }
public function hasKey($key) public function hasKey($key)
{ {
return array_key_exists($key, $this->data); return array_key_exists($key, $this->data);
} }
public function keySearch($key) public function keySearch($key)
{ {
foreach (array_keys($this->data) as $k) { foreach (array_keys($this->data) as $k) {
@@ -109,32 +109,32 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
return $k; return $k;
} }
} }
return false; return false;
} }
public function hasValue($value) public function hasValue($value)
{ {
return array_search($value, $this->data); return array_search($value, $this->data);
} }
public function replace(array $data) public function replace(?array $data)
{ {
$this->data = $data; $this->data = $data;
return $this; return $this;
} }
public function merge($data) public function merge($data)
{ {
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$this->add($key, $value); $this->add($key, $value);
} }
return $this; return $this;
} }
public function overwriteWith($data) public function overwriteWith($data)
{ {
if (is_array($data)) { if (is_array($data)) {
@@ -144,20 +144,20 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
$this->data[$key] = $value; $this->data[$key] = $value;
} }
} }
return $this; return $this;
} }
public function map(\Closure $closure, array $context = [], $static = true) public function map(\Closure $closure, ?array $context = [], $static = true)
{ {
$collection = $static ? new static() : new self(); $collection = $static ? new static() : new self();
foreach ($this as $key => $value) { foreach ($this as $key => $value) {
$collection->add($key, $closure($key, $value, $context)); $collection->add($key, $closure($key, $value, $context));
} }
return $collection; return $collection;
} }
public function filter(\Closure $closure, $static = true) public function filter(\Closure $closure, $static = true)
{ {
$collection = ($static) ? new static() : new self(); $collection = ($static) ? new static() : new self();
@@ -166,33 +166,33 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
$collection->add($key, $value); $collection->add($key, $value);
} }
} }
return $collection; return $collection;
} }
public function offsetExists($offset) public function offsetExists($offset): bool
{ {
return isset($this->data[$offset]); return isset($this->data[$offset]);
} }
public function offsetGet($offset) public function offsetGet($offset): mixed
{ {
return isset($this->data[$offset]) ? $this->data[$offset] : null; return isset($this->data[$offset]) ? $this->data[$offset] : null;
} }
public function offsetSet($offset, $value) public function offsetSet($offset, $value): void
{ {
$this->data[$offset] = $value; $this->data[$offset] = $value;
} }
public function offsetUnset($offset) public function offsetUnset($offset): void
{ {
unset($this->data[$offset]); unset($this->data[$offset]);
} }
public function setPath($path, $value) public function setPath($path, $value)
{ {
$current =& $this->data; $current = &$this->data;
$queue = explode('/', $path); $queue = explode('/', $path);
while (null !== ($key = array_shift($queue))) { while (null !== ($key = array_shift($queue))) {
if (!is_array($current)) { if (!is_array($current)) {
@@ -200,28 +200,28 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
} elseif (!$queue) { } elseif (!$queue) {
$current[$key] = $value; $current[$key] = $value;
} elseif (isset($current[$key])) { } elseif (isset($current[$key])) {
$current =& $current[$key]; $current = &$current[$key];
} else { } else {
$current[$key] = []; $current[$key] = [];
$current =& $current[$key]; $current = &$current[$key];
} }
} }
return $this; return $this;
} }
public function getPath($path, $separator = '/', $data = null) public function getPath($path, $separator = '/', $data = null)
{ {
if ($data === null) { if ($data === null) {
$data =& $this->data; $data = &$this->data;
} }
$path = is_array($path) ? $path : explode($separator, $path); $path = is_array($path) ? $path : explode($separator, $path);
while (null !== ($part = array_shift($path))) { while (null !== ($part = array_shift($path))) {
if (!is_array($data)) { if (!is_array($data)) {
return null; return null;
} elseif (isset($data[$part])) { } elseif (isset($data[$part])) {
$data =& $data[$part]; $data = &$data[$part];
} elseif ($part != '*') { } elseif ($part != '*') {
return null; return null;
} else { } else {
@@ -237,10 +237,10 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
return $result; return $result;
} }
} }
return $data; return $data;
} }
public function __toString() public function __toString()
{ {
$output = 'Debug output of '; $output = 'Debug output of ';
@@ -248,10 +248,10 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
$output = str_repeat('=', strlen($output)) . "\n" . $output . "\n" . str_repeat('=', strlen($output)) . "\n\n"; $output = str_repeat('=', strlen($output)) . "\n" . $output . "\n" . str_repeat('=', strlen($output)) . "\n\n";
$output .= "Model data\n-----------\n\n"; $output .= "Model data\n-----------\n\n";
$output .= "This data can be retrieved from the model object using the get() method of the model " $output .= "This data can be retrieved from the model object using the get() method of the model "
. "(e.g. \$model->get(\$key)) or accessing the model like an associative array (e.g. \$model['key']).\n\n"; . "(e.g. \$model->get(\$key)) or accessing the model like an associative array (e.g. \$model['key']).\n\n";
$lines = array_slice(explode("\n", trim(print_r($this->toArray(), true))), 2, -1); $lines = array_slice(explode("\n", trim(print_r($this->toArray(), true))), 2, -1);
$output .= implode("\n", $lines); $output .= implode("\n", $lines);
return $output . "\n"; return $output . "\n";
} }
} }

View File

@@ -41,7 +41,7 @@ class SdkCurlFactory implements CurlFactoryInterface
$this->maxHandles = $maxHandles; $this->maxHandles = $maxHandles;
} }
public function create(RequestInterface $request, array $options): EasyHandle public function create(?RequestInterface $request, ?array $options): EasyHandle
{ {
if (isset($options['curl']['body_as_string'])) { if (isset($options['curl']['body_as_string'])) {
$options['_body_as_string'] = $options['curl']['body_as_string']; $options['_body_as_string'] = $options['curl']['body_as_string'];
@@ -85,7 +85,7 @@ class SdkCurlFactory implements CurlFactoryInterface
} }
} }
public function release(EasyHandle $easy): void public function release(?EasyHandle $easy): void
{ {
$resource = $easy->handle; $resource = $easy->handle;
unset($easy->handle); unset($easy->handle);
@@ -102,7 +102,7 @@ class SdkCurlFactory implements CurlFactoryInterface
} }
} }
private function getDefaultConf(EasyHandle $easy) private function getDefaultConf(?EasyHandle $easy)
{ {
$conf = [ $conf = [
'_headers' => $easy->request->getHeaders(), '_headers' => $easy->request->getHeaders(),
@@ -129,7 +129,7 @@ class SdkCurlFactory implements CurlFactoryInterface
return $conf; return $conf;
} }
private function applyMethod(EasyHandle $easy, array &$conf) private function applyMethod(?EasyHandle $easy, ?array &$conf)
{ {
$body = $easy->request->getBody(); $body = $easy->request->getBody();
$size = $body->getSize(); $size = $body->getSize();
@@ -155,7 +155,7 @@ class SdkCurlFactory implements CurlFactoryInterface
} }
} }
private function applyBody(RequestInterface $request, array $options, array &$conf) private function applyBody(?RequestInterface $request, ?array $options, ?array &$conf)
{ {
$size = $request->hasHeader('Content-Length') $size = $request->hasHeader('Content-Length')
? (int) $request->getHeaderLine('Content-Length') ? (int) $request->getHeaderLine('Content-Length')
@@ -209,7 +209,7 @@ class SdkCurlFactory implements CurlFactoryInterface
} }
} }
private function applyHeaders(EasyHandle $easy, array &$conf) private function applyHeaders(?EasyHandle $easy, ?array &$conf)
{ {
foreach ($conf['_headers'] as $name => $values) { foreach ($conf['_headers'] as $name => $values) {
foreach ($values as $value) { foreach ($values as $value) {
@@ -223,7 +223,7 @@ class SdkCurlFactory implements CurlFactoryInterface
} }
} }
private function removeHeader($name, array &$options) private function removeHeader($name, ?array &$options)
{ {
foreach (array_keys($options['_headers']) as $key) { foreach (array_keys($options['_headers']) as $key) {
if (!strcasecmp($key, $name)) { if (!strcasecmp($key, $name)) {
@@ -233,7 +233,7 @@ class SdkCurlFactory implements CurlFactoryInterface
} }
} }
private function applyHandlerOptions(EasyHandle $easy, array &$conf) private function applyHandlerOptions(?EasyHandle $easy, ?array &$conf)
{ {
$options = $easy->options; $options = $easy->options;
if (isset($options['verify'])) { if (isset($options['verify'])) {
@@ -381,7 +381,7 @@ class SdkCurlFactory implements CurlFactoryInterface
} }
private function createHeaderFn(EasyHandle $easy) private function createHeaderFn(?EasyHandle $easy)
{ {
if (isset($easy->options['on_headers'])) { if (isset($easy->options['on_headers'])) {
$onHeaders = $easy->options['on_headers']; $onHeaders = $easy->options['on_headers'];

View File

@@ -38,7 +38,7 @@ class SdkStreamHandler
{ {
private $lastHeaders = []; private $lastHeaders = [];
public function __invoke(RequestInterface $request, array $options) public function __invoke(?RequestInterface $request, ?array $options)
{ {
if (isset($options['delay'])) { if (isset($options['delay'])) {
usleep($options['delay'] * 1000); usleep($options['delay'] * 1000);
@@ -77,10 +77,10 @@ class SdkStreamHandler
} }
private function invokeStats( private function invokeStats(
array $options, ?array $options,
RequestInterface $request, ?RequestInterface $request,
$startTime, $startTime,
ResponseInterface $response = null, ?ResponseInterface $response = null,
$error = null $error = null
) { ) {
if (isset($options['on_stats'])) { if (isset($options['on_stats'])) {
@@ -96,8 +96,8 @@ class SdkStreamHandler
} }
private function createResponse( private function createResponse(
RequestInterface $request, ?RequestInterface $request,
array $options, ?array $options,
$stream, $stream,
$startTime $startTime
) { ) {
@@ -141,7 +141,7 @@ class SdkStreamHandler
return new FulfilledPromise($response); return new FulfilledPromise($response);
} }
private function createSink(StreamInterface $stream, array $options) private function createSink(StreamInterface $stream, ?array $options)
{ {
if (!empty($options['stream'])) { if (!empty($options['stream'])) {
return $stream; return $stream;
@@ -156,7 +156,7 @@ class SdkStreamHandler
: \GuzzleHttp\Psr7\Utils::streamFor($sink); : \GuzzleHttp\Psr7\Utils::streamFor($sink);
} }
private function checkDecode(array $options, array $headers, $stream) private function checkDecode(?array $options, ?array $headers, $stream)
{ {
if (!empty($options['decode_content'])) { if (!empty($options['decode_content'])) {
$normalizedKeys = \GuzzleHttp\normalize_header_keys($headers); $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
@@ -232,7 +232,7 @@ class SdkStreamHandler
return $resource; return $resource;
} }
private function createStream(RequestInterface $request, array $options) private function createStream(?RequestInterface $request, ?array $options)
{ {
static $methods; static $methods;
if (!$methods) { if (!$methods) {
@@ -309,7 +309,7 @@ class SdkStreamHandler
); );
} }
private function resolveHost(RequestInterface $request, array $options) private function resolveHost(?RequestInterface $request, ?array $options)
{ {
$uri = $request->getUri(); $uri = $request->getUri();
@@ -332,7 +332,7 @@ class SdkStreamHandler
return $uri; return $uri;
} }
private function getDefaultContext(RequestInterface $request) private function getDefaultContext(?RequestInterface $request)
{ {
$headers = ''; $headers = '';
foreach ($request->getHeaders() as $name => $value) { foreach ($request->getHeaders() as $name => $value) {
@@ -365,7 +365,7 @@ class SdkStreamHandler
return $context; return $context;
} }
private function add_proxy(RequestInterface $request, &$options, $value, &$params) private function add_proxy(?RequestInterface $request, &$options, $value, &$params)
{ {
if (!is_array($value)) { if (!is_array($value)) {
$options['http']['proxy'] = $value; $options['http']['proxy'] = $value;
@@ -384,14 +384,14 @@ class SdkStreamHandler
} }
} }
private function add_timeout(RequestInterface $request, &$options, $value, &$params) private function add_timeout(?RequestInterface $request, &$options, $value, &$params)
{ {
if ($value > 0) { if ($value > 0) {
$options['http']['timeout'] = $value; $options['http']['timeout'] = $value;
} }
} }
private function add_verify(RequestInterface $request, &$options, $value, &$params) private function add_verify(?RequestInterface $request, &$options, $value, &$params)
{ {
if ($value === true) { if ($value === true) {
if (PHP_VERSION_ID < 50600) { if (PHP_VERSION_ID < 50600) {
@@ -415,7 +415,7 @@ class SdkStreamHandler
$options['ssl']['allow_self_signed'] = false; $options['ssl']['allow_self_signed'] = false;
} }
private function add_cert(RequestInterface $request, &$options, $value, &$params) private function add_cert(?RequestInterface $request, &$options, $value, &$params)
{ {
if (is_array($value)) { if (is_array($value)) {
$options['ssl']['passphrase'] = $value[1]; $options['ssl']['passphrase'] = $value[1];
@@ -429,7 +429,7 @@ class SdkStreamHandler
$options['ssl']['local_cert'] = $value; $options['ssl']['local_cert'] = $value;
} }
private function add_progress(RequestInterface $request, &$options, $value, &$params) private function add_progress(?RequestInterface $request, &$options, $value, &$params)
{ {
$this->addNotification( $this->addNotification(
$params, $params,
@@ -441,7 +441,7 @@ class SdkStreamHandler
); );
} }
private function add_debug(RequestInterface $request, &$options, $value, &$params) private function add_debug(?RequestInterface $request, &$options, $value, &$params)
{ {
if ($value === false) { if ($value === false) {
return; return;
@@ -478,7 +478,7 @@ class SdkStreamHandler
); );
} }
private function addNotification(array &$params, callable $notify) private function addNotification(?array &$params, callable $notify)
{ {
if (!isset($params['notification'])) { if (!isset($params['notification'])) {
$params['notification'] = $notify; $params['notification'] = $notify;
@@ -490,7 +490,7 @@ class SdkStreamHandler
} }
} }
private function callArray(array $functions) private function callArray(?array $functions)
{ {
return function () use ($functions) { return function () use ($functions) {
$args = func_get_args(); $args = func_get_args();