fix(hwobs): 升级华为OBS云储存

This commit is contained in:
2025-05-10 19:50:27 +08:00
parent e0e42e3ecc
commit 12adc51eeb
4 changed files with 182 additions and 175 deletions

View File

@@ -1 +1 @@
{"files":["public\\assets\\addons\\hwobs\\js\\spark.js"],"license":"regular","licenseto":"34485","licensekey":"kaCpXL6B57yO89Rv h7EIXhuMw6+sCcUldTSJoQ==","domains":["localhost"],"licensecodes":[],"validations":["757319b447175b6ca1882635b132a594"]} {"files":["public\\assets\\addons\\hwobs\\js\\spark.js"],"license":"regular","licenseto":"34485","licensekey":"fE1oqlUNvPsVy07I LHfdNbd7Yb6AD1LjzKfdIA==","domains":[],"licensecodes":[],"validations":[]}

View File

@@ -2,244 +2,244 @@
return [ return [
[ [
'name' => 'accessKey', 'name' => 'accessKey',
'title' => 'Access Key', 'title' => 'Access Key',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => '', 'value' => '',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '请前往华为云控制台->我的凭证->访问密钥中生成', 'tip' => '请前往华为云控制台->我的凭证->访问密钥中生成',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'secretKey', 'name' => 'secretKey',
'title' => 'Secret Key', 'title' => 'Secret Key',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => '', 'value' => '',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '请前往华为云控制台->我的凭证->访问密钥中生成', 'tip' => '请前往华为云控制台->我的凭证->访问密钥中生成',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'bucket', 'name' => 'bucket',
'title' => '存储桶名称', 'title' => '存储桶名称',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => 'yourbucket', 'value' => 'yourbucket',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '存储桶名称', 'tip' => '存储桶名称',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'endpoint', 'name' => 'endpoint',
'title' => 'Endpoint', 'title' => 'Endpoint',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => 'obs.cn-south-1.myhuaweicloud.com', 'value' => 'obs.cn-south-1.myhuaweicloud.com',
'rule' => 'required;endpoint', 'rule' => 'required;endpoint',
'msg' => '', 'msg' => '',
'tip' => '请输入你的Endpoint', 'tip' => '请输入你的Endpoint',
'ok' => '', 'ok' => '',
'extend' => 'data-rule-endpoint="[/^(?!http(s)?:\/\/).*$/, \'不能以http(s)://开头\']"', 'extend' => 'data-rule-endpoint="[/^(?!http(s)?:\\/\\/).*$/, \'不能以http(s)://开头\']"',
], ],
[ [
'name' => 'uploadurl', 'name' => 'uploadurl',
'title' => '上传接口地址', 'title' => '上传接口地址',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => 'https://yourbucket.obs.cn-south-1.myhuaweicloud.com', 'value' => 'https://yourbucket.obs.cn-south-1.myhuaweicloud.com',
'rule' => 'required;uploadurl', 'rule' => 'required;uploadurl',
'msg' => '', 'msg' => '',
'tip' => '请使用存储桶->基本信息->访问域名的值并在前面加上http://或https://', 'tip' => '请使用存储桶->基本信息->访问域名的值并在前面加上http://或https://',
'ok' => '', 'ok' => '',
'extend' => 'data-rule-uploadurl="[/^http(s)?:\/\/.*$/, \'必需以http(s)://开头\']"', 'extend' => 'data-rule-uploadurl="[/^http(s)?:\\/\\/.*$/, \'必需以http(s)://开头\']"',
], ],
[ [
'name' => 'cdnurl', 'name' => 'cdnurl',
'title' => 'CDN地址', 'title' => 'CDN地址',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => 'https://yourbucket.obs.cn-south-1.myhuaweicloud.com', 'value' => 'https://yourbucket.obs.cn-south-1.myhuaweicloud.com',
'rule' => 'required;cdnurl', 'rule' => 'required;cdnurl',
'msg' => '', 'msg' => '',
'tip' => '如果你的云存储有绑定自定义域名,请输入自定义域名', 'tip' => '如果你的云存储有绑定自定义域名,请输入自定义域名',
'ok' => '', 'ok' => '',
'extend' => 'data-rule-cdnurl="[/^http(s)?:\/\/.*$/, \'必需以http(s)://开头\']"', 'extend' => 'data-rule-cdnurl="[/^http(s)?:\\/\\/.*$/, \'必需以http(s)://开头\']"',
], ],
[ [
'name' => 'uploadmode', 'name' => 'uploadmode',
'title' => '上传模式', 'title' => '上传模式',
'type' => 'select', 'type' => 'select',
'content' => [ 'content' => [
'client' => '客户端直传(速度快,无备份)', 'client' => '客户端直传(速度快,无备份)',
'server' => '服务器中转(占用服务器带宽,有备份)', 'server' => '服务器中转(占用服务器带宽,有备份)',
], ],
'value' => 'server', 'value' => 'server',
'rule' => '', 'rule' => '',
'msg' => '', 'msg' => '',
'tip' => '', 'tip' => '',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'serverbackup', 'name' => 'serverbackup',
'title' => '服务器中转模式备份', 'title' => '服务器中转模式备份',
'type' => 'radio', 'type' => 'radio',
'content' => [ 'content' => [
1 => '备份(附件管理将产生2条记录)', 1 => '备份(附件管理将产生2条记录)',
0 => '不备份', 0 => '不备份',
], ],
'value' => '1', 'value' => '1',
'rule' => '', 'rule' => '',
'msg' => '', 'msg' => '',
'tip' => '服务器中转模式下是否备份文件', 'tip' => '服务器中转模式下是否备份文件',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'savekey', 'name' => 'savekey',
'title' => '保存文件名', 'title' => '保存文件名',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => '/uploads/{year}{mon}{day}/{filemd5}{.suffix}', 'value' => '/uploads/{year}{mon}{day}/{filemd5}{.suffix}',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '', 'tip' => '',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'expire', 'name' => 'expire',
'title' => '上传有效时长', 'title' => '上传有效时长',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => '600', 'value' => '600',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '用户停留页面上传有效时长,单位秒', 'tip' => '用户停留页面上传有效时长,单位秒',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'maxsize', 'name' => 'maxsize',
'title' => '最大可上传', 'title' => '最大可上传',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => '10M', 'value' => '10M',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '', 'tip' => '',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'mimetype', 'name' => 'mimetype',
'title' => '可上传后缀格式', 'title' => '可上传后缀格式',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => 'jpg,png,bmp,jpeg,gif,zip,rar,xls,xlsx', 'value' => 'jpg,png,bmp,jpeg,gif,zip,rar,xls,xlsx',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '', 'tip' => '',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'multiple', 'name' => 'multiple',
'title' => '多文件上传', 'title' => '多文件上传',
'type' => 'bool', 'type' => 'bool',
'content' => [], 'content' => [],
'value' => '0', 'value' => '0',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '', 'tip' => '',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'thumbstyle', 'name' => 'thumbstyle',
'title' => '缩略图样式', 'title' => '缩略图样式',
'type' => 'string', 'type' => 'string',
'content' => [], 'content' => [],
'value' => '', 'value' => '',
'rule' => '', 'rule' => '',
'msg' => '', 'msg' => '',
'tip' => '用于后台列表缩略图样式,可使用:?x-image-process=image/resize,m_fixed,h_90,w_120或?x-image-process=style/样式名称', 'tip' => '用于后台列表缩略图样式,可使用:?x-image-process=image/resize,m_fixed,h_90,w_120或?x-image-process=style/样式名称',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'chunking', 'name' => 'chunking',
'title' => '分片上传', 'title' => '分片上传',
'type' => 'radio', 'type' => 'radio',
'content' => [ 'content' => [
1 => '开启', 1 => '开启',
0 => '关闭', 0 => '关闭',
], ],
'value' => '0', 'value' => '0',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '', 'tip' => '',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'chunksize', 'name' => 'chunksize',
'title' => '分片大小', 'title' => '分片大小',
'type' => 'number', 'type' => 'number',
'content' => [], 'content' => [],
'value' => '4194304', 'value' => '4194304',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '', 'tip' => '',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'syncdelete', 'name' => 'syncdelete',
'title' => '附件删除时是否同步删除云存储文件', 'title' => '附件删除时是否同步删除云存储文件',
'type' => 'bool', 'type' => 'bool',
'content' => [], 'content' => [],
'value' => '0', 'value' => '0',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '', 'tip' => '',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'apiupload', 'name' => 'apiupload',
'title' => 'API接口使用云存储', 'title' => 'API接口使用云存储',
'type' => 'bool', 'type' => 'bool',
'content' => [], 'content' => [],
'value' => '0', 'value' => '0',
'rule' => 'required', 'rule' => 'required',
'msg' => '', 'msg' => '',
'tip' => '', 'tip' => '',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
[ [
'name' => 'noneedlogin', 'name' => 'noneedlogin',
'title' => '免登录上传', 'title' => '免登录上传',
'type' => 'checkbox', 'type' => 'checkbox',
'content' => [ 'content' => [
'api' => 'API', 'api' => 'API',
'index' => '前台', 'index' => '前台',
'admin' => '后台', 'admin' => '后台',
], ],
'value' => '', 'value' => '',
'rule' => '', 'rule' => '',
'msg' => '', 'msg' => '',
'tip' => '', 'tip' => '',
'ok' => '', 'ok' => '',
'extend' => '', 'extend' => '',
], ],
]; ];

View File

@@ -39,6 +39,14 @@ class Index extends Controller
$name = $this->request->post('name'); $name = $this->request->post('name');
$md5 = $this->request->post('md5'); $md5 = $this->request->post('md5');
$chunk = $this->request->post('chunk'); $chunk = $this->request->post('chunk');
$name = xss_clean($name);
// 检查文件后缀
$extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
$allowedExtensions = explode(',', strtolower($config['mimetype']));
if (!in_array($extension, $allowedExtensions) || in_array($extension, ['php', 'html', 'htm', 'phar', 'phtml']) || preg_match("/^php(.*)/i", $extension)) {
$this->error('不允许的文件类型');
}
$key = (new Upload())->getSavekey($config['savekey'], $name, $md5); $key = (new Upload())->getSavekey($config['savekey'], $name, $md5);
$key = ltrim($key, "/"); $key = ltrim($key, "/");
@@ -86,7 +94,6 @@ class Index extends Controller
$params['headers'] = $headers; $params['headers'] = $headers;
$params['date'] = $date; $params['date'] = $date;
$this->success('', null, $params); $this->success('', null, $params);
return;
} }
/** /**

View File

@@ -3,7 +3,7 @@ title = 华为OBS云储存
intro = 使用华为OBS作为默认云储存 intro = 使用华为OBS作为默认云储存
author = FastAdmin author = FastAdmin
website = https://www.fastadmin.net website = https://www.fastadmin.net
version = 1.2.9 version = 1.2.10
state = 1 state = 1
url = /addons/hwobs url = /addons/hwobs
license = regular license = regular