修复华为云存储报错

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

View File

@@ -28,17 +28,17 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
{
protected $data;
public function __construct(array $data = [])
public function __construct(?array $data = [])
{
$this->data = $data;
}
public function count()
public function count(): int
{
return count($this->data);
}
public function getIterator()
public function getIterator(): \Traversable
{
return new \ArrayIterator($this->data);
}
@@ -55,7 +55,7 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
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;
}
@@ -119,7 +119,7 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
return array_search($value, $this->data);
}
public function replace(array $data)
public function replace(?array $data)
{
$this->data = $data;
@@ -148,7 +148,7 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
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();
foreach ($this as $key => $value) {
@@ -170,29 +170,29 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
return $collection;
}
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return isset($this->data[$offset]);
}
public function offsetGet($offset)
public function offsetGet($offset): mixed
{
return isset($this->data[$offset]) ? $this->data[$offset] : null;
}
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->data[$offset] = $value;
}
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
unset($this->data[$offset]);
}
public function setPath($path, $value)
{
$current =& $this->data;
$current = &$this->data;
$queue = explode('/', $path);
while (null !== ($key = array_shift($queue))) {
if (!is_array($current)) {
@@ -200,10 +200,10 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
} elseif (!$queue) {
$current[$key] = $value;
} elseif (isset($current[$key])) {
$current =& $current[$key];
$current = &$current[$key];
} else {
$current[$key] = [];
$current =& $current[$key];
$current = &$current[$key];
}
}
@@ -213,7 +213,7 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
public function getPath($path, $separator = '/', $data = null)
{
if ($data === null) {
$data =& $this->data;
$data = &$this->data;
}
$path = is_array($path) ? $path : explode($separator, $path);
@@ -221,7 +221,7 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
if (!is_array($data)) {
return null;
} elseif (isset($data[$part])) {
$data =& $data[$part];
$data = &$data[$part];
} elseif ($part != '*') {
return null;
} else {
@@ -248,7 +248,7 @@ class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInte
$output = str_repeat('=', strlen($output)) . "\n" . $output . "\n" . str_repeat('=', strlen($output)) . "\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 "
. "(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);
$output .= implode("\n", $lines);

View File

@@ -41,7 +41,7 @@ class SdkCurlFactory implements CurlFactoryInterface
$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'])) {
$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;
unset($easy->handle);
@@ -102,7 +102,7 @@ class SdkCurlFactory implements CurlFactoryInterface
}
}
private function getDefaultConf(EasyHandle $easy)
private function getDefaultConf(?EasyHandle $easy)
{
$conf = [
'_headers' => $easy->request->getHeaders(),
@@ -129,7 +129,7 @@ class SdkCurlFactory implements CurlFactoryInterface
return $conf;
}
private function applyMethod(EasyHandle $easy, array &$conf)
private function applyMethod(?EasyHandle $easy, ?array &$conf)
{
$body = $easy->request->getBody();
$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')
? (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 ($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) {
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;
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'])) {
$onHeaders = $easy->options['on_headers'];

View File

@@ -38,7 +38,7 @@ class SdkStreamHandler
{
private $lastHeaders = [];
public function __invoke(RequestInterface $request, array $options)
public function __invoke(?RequestInterface $request, ?array $options)
{
if (isset($options['delay'])) {
usleep($options['delay'] * 1000);
@@ -77,10 +77,10 @@ class SdkStreamHandler
}
private function invokeStats(
array $options,
RequestInterface $request,
?array $options,
?RequestInterface $request,
$startTime,
ResponseInterface $response = null,
?ResponseInterface $response = null,
$error = null
) {
if (isset($options['on_stats'])) {
@@ -96,8 +96,8 @@ class SdkStreamHandler
}
private function createResponse(
RequestInterface $request,
array $options,
?RequestInterface $request,
?array $options,
$stream,
$startTime
) {
@@ -141,7 +141,7 @@ class SdkStreamHandler
return new FulfilledPromise($response);
}
private function createSink(StreamInterface $stream, array $options)
private function createSink(StreamInterface $stream, ?array $options)
{
if (!empty($options['stream'])) {
return $stream;
@@ -156,7 +156,7 @@ class SdkStreamHandler
: \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'])) {
$normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
@@ -232,7 +232,7 @@ class SdkStreamHandler
return $resource;
}
private function createStream(RequestInterface $request, array $options)
private function createStream(?RequestInterface $request, ?array $options)
{
static $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();
@@ -332,7 +332,7 @@ class SdkStreamHandler
return $uri;
}
private function getDefaultContext(RequestInterface $request)
private function getDefaultContext(?RequestInterface $request)
{
$headers = '';
foreach ($request->getHeaders() as $name => $value) {
@@ -365,7 +365,7 @@ class SdkStreamHandler
return $context;
}
private function add_proxy(RequestInterface $request, &$options, $value, &$params)
private function add_proxy(?RequestInterface $request, &$options, $value, &$params)
{
if (!is_array($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) {
$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 (PHP_VERSION_ID < 50600) {
@@ -415,7 +415,7 @@ class SdkStreamHandler
$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)) {
$options['ssl']['passphrase'] = $value[1];
@@ -429,7 +429,7 @@ class SdkStreamHandler
$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(
$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) {
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'])) {
$params['notification'] = $notify;
@@ -490,7 +490,7 @@ class SdkStreamHandler
}
}
private function callArray(array $functions)
private function callArray(?array $functions)
{
return function () use ($functions) {
$args = func_get_args();