mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
ComposerUpdate 增加文件链接配置
This commit is contained in:
parent
592142cc87
commit
b85978f0a6
@ -63,19 +63,19 @@ class Upload extends Controller
|
|||||||
$data['url'] = $info['url'];
|
$data['url'] = $info['url'];
|
||||||
$this->success('文件已经上传', $data, 200);
|
$this->success('文件已经上传', $data, 200);
|
||||||
} elseif ('local' === $data['uptype']) {
|
} elseif ('local' === $data['uptype']) {
|
||||||
$data['url'] = LocalStorage::instance()->url($data['xkey']);
|
$data['url'] = LocalStorage::instance()->url($data['xkey'], $this->safe, $this->name);
|
||||||
$data['server'] = LocalStorage::instance()->upload();
|
$data['server'] = LocalStorage::instance()->upload();
|
||||||
} elseif ('qiniu' === $data['uptype']) {
|
} elseif ('qiniu' === $data['uptype']) {
|
||||||
$data['url'] = QiniuStorage::instance()->url($data['xkey']);
|
$data['url'] = QiniuStorage::instance()->url($data['xkey'], $this->safe, $this->name);
|
||||||
$data['token'] = QiniuStorage::instance()->buildUploadToken($data['xkey'], 3600, $this->name);
|
$data['token'] = QiniuStorage::instance()->buildUploadToken($data['xkey'], 3600, $this->name);
|
||||||
$data['server'] = QiniuStorage::instance()->upload();
|
$data['server'] = QiniuStorage::instance()->upload();
|
||||||
} elseif ('alioss' === $data['uptype']) {
|
} elseif ('alioss' === $data['uptype']) {
|
||||||
$token = AliossStorage::instance()->buildUploadToken($data['xkey']);
|
$token = AliossStorage::instance()->buildUploadToken($data['xkey'], 3600, $this->name);
|
||||||
$data['server'] = AliossStorage::instance()->upload();
|
|
||||||
$data['url'] = $token['siteurl'];
|
$data['url'] = $token['siteurl'];
|
||||||
$data['policy'] = $token['policy'];
|
$data['policy'] = $token['policy'];
|
||||||
$data['signature'] = $token['signature'];
|
$data['signature'] = $token['signature'];
|
||||||
$data['OSSAccessKeyId'] = $token['keyid'];
|
$data['OSSAccessKeyId'] = $token['keyid'];
|
||||||
|
$data['server'] = AliossStorage::instance()->upload();
|
||||||
}
|
}
|
||||||
$data['safe'] = intval($this->safe);
|
$data['safe'] = intval($this->safe);
|
||||||
$this->success('获取上传参数', $data, 404);
|
$this->success('获取上传参数', $data, 404);
|
||||||
|
@ -28,7 +28,7 @@ define(['md5'], function (SparkMD5, allowExtsMimes) {
|
|||||||
opt.element.data('file', file).data('index', index);
|
opt.element.data('file', file).data('index', index);
|
||||||
jQuery.ajax("{:url('@admin/api.upload/state')}", {
|
jQuery.ajax("{:url('@admin/api.upload/state')}", {
|
||||||
data: {xkey: file.xkey, uptype: opt.uptype, safe: opt.safe, name: file.name}, method: 'post', success: function (ret) {
|
data: {xkey: file.xkey, uptype: opt.uptype, safe: opt.safe, name: file.name}, method: 'post', success: function (ret) {
|
||||||
file.xurl = ret.data.url + (ret.data.url.indexOf('?attname=') > -1 ? '' : '?attname=' + encodeURIComponent(file.name));
|
file.xurl = ret.data.url;
|
||||||
if (parseInt(ret.code) === 404) {
|
if (parseInt(ret.code) === 404) {
|
||||||
uploader.config.url = ret.data.server;
|
uploader.config.url = ret.data.server;
|
||||||
uploader.config.data.key = ret.data.xkey;
|
uploader.config.data.key = ret.data.xkey;
|
||||||
|
27
app/admin/view/config/storage-0.html
Normal file
27
app/admin/view/config/storage-0.html
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label label-required">
|
||||||
|
<span class="color-green font-w7">LinkType</span><br><span class="nowrap color-desc">链接类型</span>
|
||||||
|
</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
{foreach ['link_type_none'=>'简洁链接','link_type_full'=>'完整链接'] as $k=>$v}
|
||||||
|
<label class="think-radio">
|
||||||
|
{if sysconf('storage.link_type') eq $k}
|
||||||
|
<input checked type="radio" name="storage.link_type" value="{$k}" lay-ignore> {$v}
|
||||||
|
{else}
|
||||||
|
<input type="radio" name="storage.link_type" value="{$k}" lay-ignore> {$v}
|
||||||
|
{/if}
|
||||||
|
</label>
|
||||||
|
{/foreach}
|
||||||
|
<p class="help-block">类型为“简洁链接”时链接将只返回 hash 地址,而“完整链接”将携带参数保留文件名称</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label" for="storage.allow_exts">
|
||||||
|
<span class="color-green font-w7">AllowExts</span><br><span class="nowrap color-desc">允许类型</span>
|
||||||
|
</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input id="storage.allow_exts" type="text" name="storage.allow_exts" required value="{:sysconf('storage.allow_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input">
|
||||||
|
<p class="help-block">设置系统允许上传文件的后缀,多个以英文逗号隔开如:png,jpg,rar,doc</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -6,15 +6,7 @@
|
|||||||
<p>直传需要配置跨域规则,设置来源为 *,允许 Methods 为 POST,允许 Headers 为 *</p>
|
<p>直传需要配置跨域规则,设置来源为 *,允许 Methods 为 POST,允许 Headers 为 *</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="layui-form-item">
|
{include file='config/storage-0'}
|
||||||
<label class="layui-form-label" for="storage.allow_exts">
|
|
||||||
<span class="color-green font-w7">AllowExts</span><br><span class="nowrap color-desc">允许类型</span>
|
|
||||||
</label>
|
|
||||||
<div class="layui-input-block">
|
|
||||||
<input id="storage.allow_exts" type="text" name="storage.allow_exts" required value="{:sysconf('storage.allow_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input">
|
|
||||||
<p class="help-block">设置系统允许上传文件的后缀,多个以英文逗号隔开如:png,jpg,rar,doc</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label label-required">
|
<label class="layui-form-label label-required">
|
||||||
|
@ -6,15 +6,7 @@
|
|||||||
<p>文件存储的目录需要有读写权限,有足够的存储空间</p>
|
<p>文件存储的目录需要有读写权限,有足够的存储空间</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="layui-form-item">
|
{include file='config/storage-0'}
|
||||||
<label class="layui-form-label" for="storage.allow_exts">
|
|
||||||
<span class="color-green font-w7">AllowExts</span><br><span class="nowrap color-desc">允许类型</span>
|
|
||||||
</label>
|
|
||||||
<div class="layui-input-block">
|
|
||||||
<input id="storage.allow_exts" type="text" name="storage.allow_exts" required value="{:sysconf('storage.allow_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input">
|
|
||||||
<p class="help-block">设置系统允许上传文件的后缀,多个以英文逗号隔开。如:png,jpg,rar,doc</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label label-required">
|
<label class="layui-form-label label-required">
|
||||||
|
@ -6,15 +6,7 @@
|
|||||||
完成实名认证后可获得10G免费存储空间哦!<a target="_blank" href="https://portal.qiniu.com/signup?code=3lhz6nmnwbple">我要免费申请</a>
|
完成实名认证后可获得10G免费存储空间哦!<a target="_blank" href="https://portal.qiniu.com/signup?code=3lhz6nmnwbple">我要免费申请</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="layui-form-item">
|
{include file='config/storage-0'}
|
||||||
<label class="layui-form-label" for="storage.allow_exts">
|
|
||||||
<span class="color-green font-w7">AllowExts</span><br><span class="nowrap color-desc">允许类型</span>
|
|
||||||
</label>
|
|
||||||
<div class="layui-input-block">
|
|
||||||
<input id="storage.allow_exts" type="text" name="storage.allow_exts" required value="{:sysconf('storage.allow_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input">
|
|
||||||
<p class="help-block">设置系统允许上传文件的后缀,多个以英文逗号隔开如:png,jpg,rar,doc</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label label-required">
|
<label class="layui-form-label label-required">
|
||||||
|
8
composer.lock
generated
8
composer.lock
generated
@ -909,12 +909,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||||
"reference": "65ff43be42fcf43679c8d05a416d8b25d70b7dbf"
|
"reference": "d2a8d9065308d0ce7b5d4e8ac916bb2a5095cb4c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/65ff43be42fcf43679c8d05a416d8b25d70b7dbf",
|
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/d2a8d9065308d0ce7b5d4e8ac916bb2a5095cb4c",
|
||||||
"reference": "65ff43be42fcf43679c8d05a416d8b25d70b7dbf",
|
"reference": "d2a8d9065308d0ce7b5d4e8ac916bb2a5095cb4c",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -958,7 +958,7 @@
|
|||||||
],
|
],
|
||||||
"description": "ThinkPHP v6.0 Development Library",
|
"description": "ThinkPHP v6.0 Development Library",
|
||||||
"homepage": "http://framework.thinkadmin.top",
|
"homepage": "http://framework.thinkadmin.top",
|
||||||
"time": "2020-01-13T07:49:16+00:00"
|
"time": "2020-01-13T08:52:47+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "zoujingli/wechat-developer",
|
"name": "zoujingli/wechat-developer",
|
||||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -935,12 +935,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||||
"reference": "65ff43be42fcf43679c8d05a416d8b25d70b7dbf"
|
"reference": "d2a8d9065308d0ce7b5d4e8ac916bb2a5095cb4c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/65ff43be42fcf43679c8d05a416d8b25d70b7dbf",
|
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/d2a8d9065308d0ce7b5d4e8ac916bb2a5095cb4c",
|
||||||
"reference": "65ff43be42fcf43679c8d05a416d8b25d70b7dbf",
|
"reference": "d2a8d9065308d0ce7b5d4e8ac916bb2a5095cb4c",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -956,7 +956,7 @@
|
|||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"topthink/framework": "^6.0"
|
"topthink/framework": "^6.0"
|
||||||
},
|
},
|
||||||
"time": "2020-01-13T07:49:16+00:00",
|
"time": "2020-01-13T08:52:47+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"think": {
|
"think": {
|
||||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
// This file is automatically generated at:2020-01-13 16:07:29
|
// This file is automatically generated at:2020-01-13 16:54:27
|
||||||
declare (strict_types = 1);
|
declare (strict_types = 1);
|
||||||
return array (
|
return array (
|
||||||
0 => 'think\\app\\Service',
|
0 => 'think\\app\\Service',
|
||||||
|
11
vendor/zoujingli/think-library/src/Storage.php
vendored
11
vendor/zoujingli/think-library/src/Storage.php
vendored
@ -184,15 +184,18 @@ abstract class Storage
|
|||||||
* 获取下载链接后缀
|
* 获取下载链接后缀
|
||||||
* @param string $attname 下载名称
|
* @param string $attname 下载名称
|
||||||
* @return string
|
* @return string
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
protected function getSuffix($attname = null)
|
protected function getSuffix($attname = null)
|
||||||
{
|
{
|
||||||
|
if (sysconf('storage.link_type') === 'link_type_full') {
|
||||||
if (is_string($attname) && strlen($attname) > 0) {
|
if (is_string($attname) && strlen($attname) > 0) {
|
||||||
$attname = "?attname=" . urlencode($attname);
|
return "?attname=" . urlencode($attname);
|
||||||
} else {
|
|
||||||
$attname = '';
|
|
||||||
}
|
}
|
||||||
return $attname;
|
}
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -215,16 +215,17 @@ class AliossStorage extends Storage
|
|||||||
* 获取文件上传令牌
|
* 获取文件上传令牌
|
||||||
* @param string $name 文件名称
|
* @param string $name 文件名称
|
||||||
* @param integer $expires 有效时间
|
* @param integer $expires 有效时间
|
||||||
|
* @param string $attname 下载名称
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function buildUploadToken($name = null, $expires = 3600)
|
public function buildUploadToken($name = null, $expires = 3600, $attname = null)
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'policy' => base64_encode(json_encode([
|
'policy' => base64_encode(json_encode([
|
||||||
'conditions' => [['content-length-range', 0, 1048576000]],
|
'conditions' => [['content-length-range', 0, 1048576000]],
|
||||||
'expiration' => date('Y-m-d\TH:i:s.000\Z', time() + $expires),
|
'expiration' => date('Y-m-d\TH:i:s.000\Z', time() + $expires),
|
||||||
])),
|
])),
|
||||||
'siteurl' => $this->url($name),
|
'siteurl' => $this->url($name, false, $attname),
|
||||||
'keyid' => $this->accessKey,
|
'keyid' => $this->accessKey,
|
||||||
];
|
];
|
||||||
$data['signature'] = base64_encode(hash_hmac('sha1', $data['policy'], $this->secretKey, true));
|
$data['signature'] = base64_encode(hash_hmac('sha1', $data['policy'], $this->secretKey, true));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user