[更新]修改腾讯云文件上传

This commit is contained in:
Anyon 2020-12-10 11:51:34 +08:00
parent 05d15cd9ec
commit fee35392e9
5 changed files with 16 additions and 14 deletions

View File

@ -83,6 +83,7 @@ class Upload extends Controller
$data['q-ak'] = $token['q-ak'];
$data['policy'] = $token['policy'];
$data['q-key-time'] = $token['q-key-time'];
$data['q-signature'] = $token['q-signature'];
$data['q-sign-algorithm'] = $token['q-sign-algorithm'];
$data['server'] = TxcosStorage::instance()->upload();
}

View File

@ -34,17 +34,18 @@ define(['md5'], function (SparkMD5, allowMime) {
if (ret.data.uptype === 'qiniu') {
option.uploader.config.data.token = ret.data.token;
} else if (ret.data.uptype === 'alioss') {
option.uploader.config.data.policy = ret.data.policy;
option.uploader.config.data.signature = ret.data.signature;
option.uploader.config.data.OSSAccessKeyId = ret.data.OSSAccessKeyId;
option.uploader.config.data.success_action_status = 200;
option.uploader.config.data['policy'] = ret.data.policy;
option.uploader.config.data['signature'] = ret.data.signature;
option.uploader.config.data['OSSAccessKeyId'] = ret.data.OSSAccessKeyId;
option.uploader.config.data['success_action_status'] = 200;
option.uploader.config.data['Content-Disposition'] = 'inline;filename=' + encodeURIComponent(file.name);
} else if (ret.data.uptype === 'txcos') {
option.uploader.config.data.policy = ret.data.policy;
option.uploader.config.data['policy'] = ret.data.policy;
option.uploader.config.data['q-ak'] = ret.data['q-ak'];
option.uploader.config.data['q-key-time'] = ret.data['q-key-time'];
option.uploader.config.data['q-signature'] = ret.data['q-signature'];
option.uploader.config.data['q-sign-algorithm'] = ret.data['q-sign-algorithm'];
option.uploader.config.data.success_action_status = 200;
option.uploader.config.data['success_action_status'] = 200;
option.uploader.config.data['Content-Disposition'] = 'inline;filename=' + encodeURIComponent(file.name);
}
object.upload(file.index, file);

View File

@ -937,12 +937,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "6f2b994b642a808ae10c1502edb8e5e92b2fff27"
"reference": "a8a7d6568b7ce7fe43c4ee7920a0b2d352e58b4c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/6f2b994b642a808ae10c1502edb8e5e92b2fff27",
"reference": "6f2b994b642a808ae10c1502edb8e5e92b2fff27",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/a8a7d6568b7ce7fe43c4ee7920a0b2d352e58b4c",
"reference": "a8a7d6568b7ce7fe43c4ee7920a0b2d352e58b4c",
"shasum": "",
"mirrors": [
{
@ -959,7 +959,7 @@
"ext-mbstring": "*",
"topthink/framework": "^6.0"
},
"time": "2020-11-30T06:08:44+00:00",
"time": "2020-12-10T03:45:59+00:00",
"type": "library",
"extra": {
"think": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php
// This file is automatically generated at:2020-12-09 16:19:09
// This file is automatically generated at:2020-12-10 11:50:32
declare (strict_types = 1);
return array (
0 => 'think\\admin\\Library',

View File

@ -205,9 +205,9 @@ class TxcosStorage extends Storage
'conditions' => [['q-ak' => $this->secretId], ['q-sign-time' => $keyTime], ['q-sign-algorithm' => 'sha1']],
]);
return [
'policy' => base64_encode($policy), 'q-ak' => $this->secretId,
'siteurl' => $siteurl, 'q-key-time' => $keyTime, 'q-sign-algorithm' => 'sha1',
// 'q-signature' => hash_hmac('sha1', sha1($policy), hash_hmac('sha1', $keyTime, $this->secretKey)),
'policy' => base64_encode($policy), 'q-ak' => $this->secretId,
'siteurl' => $siteurl, 'q-key-time' => $keyTime, 'q-sign-algorithm' => 'sha1',
'q-signature' => hash_hmac('sha1', sha1($policy), hash_hmac('sha1', $keyTime, $this->secretKey)),
];
}