开始腾讯提交;

This commit is contained in:
2022-07-11 18:39:21 +08:00
parent 1e2c75fbbe
commit bfcb4ad321
7 changed files with 84 additions and 3 deletions

View File

@@ -71,6 +71,7 @@ class Ajax extends AdminController
$result = $upload_service->save($data['file']); $result = $upload_service->save($data['file']);
} catch (\Exception $e) { } catch (\Exception $e) {
throw $e;
$this->error($e->getMessage()); $this->error($e->getMessage());
} }

View File

@@ -241,6 +241,9 @@ function build_upload_url($url)
case 'alioss': case 'alioss':
$prefix_url = $config['alioss_domain']; $prefix_url = $config['alioss_domain'];
break; break;
// case 'alioss':
// $prefix_url = $config['alioss_domain'];
// break;
default: default:
# code... # code...

View File

@@ -70,7 +70,7 @@ class UploadService
$save_name = Filesystem::disk($this->uploadType)->putFile('upload', $file, function () { $save_name = Filesystem::disk($this->uploadType)->putFile('upload', $file, function () {
return date('Ymd') . DIRECTORY_SEPARATOR . uniqid(); return date('Ymd') . '/' . uniqid();
}); });
$url = build_upload_url($save_name); $url = build_upload_url($save_name);

View File

@@ -30,7 +30,8 @@
"phpoffice/phpspreadsheet": "^1.22", "phpoffice/phpspreadsheet": "^1.22",
"topthink/think-migration": "^3.0", "topthink/think-migration": "^3.0",
"overtrue/flysystem-qiniu": "*", "overtrue/flysystem-qiniu": "*",
"xxtime/flysystem-aliyun-oss": "^1.5" "xxtime/flysystem-aliyun-oss": "^1.5",
"chunpat/flysystem-tencent-cos": "^0.0.1"
}, },
"require-dev": { "require-dev": {
"symfony/var-dumper": "^4.2", "symfony/var-dumper": "^4.2",

39
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "111f94878583850a9fed799619afc3d7", "content-hash": "2dae06d14067806fb0de04359c23b7e7",
"packages": [ "packages": [
{ {
"name": "aliyuncs/oss-sdk-php", "name": "aliyuncs/oss-sdk-php",
@@ -46,6 +46,43 @@
"homepage": "http://www.aliyun.com/product/oss/", "homepage": "http://www.aliyun.com/product/oss/",
"time": "2022-05-13T07:41:28+00:00" "time": "2022-05-13T07:41:28+00:00"
}, },
{
"name": "chunpat/flysystem-tencent-cos",
"version": "0.0.1",
"source": {
"type": "git",
"url": "https://github.com/chunpat/flysystem-tencent-cos.git",
"reference": "ef53f4aea50614055b4ea785e742a09a011b9c0c"
},
"dist": {
"type": "zip",
"url": "https://repo.huaweicloud.com/repository/php/chunpat/flysystem-tencent-cos/0.0.1/chunpat-flysystem-tencent-cos-0.0.1.zip",
"reference": "ef53f4aea50614055b4ea785e742a09a011b9c0c",
"shasum": ""
},
"require": {
"league/flysystem": "^1.0",
"php": ">=7.1.0",
"qcloud/cos-sdk-v5": "^2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Chunpat\\FlysystemTencentCos\\": "src"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "chunpat",
"email": "chunpat@163.com"
}
],
"description": "Package description here.",
"time": "2020-06-22T17:18:34+00:00"
},
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
"version": "1.13.3", "version": "1.13.3",

View File

@@ -27,6 +27,9 @@ return [
'alioss' => [ 'alioss' => [
'type' => 'Alioss' 'type' => 'Alioss'
], ],
'txcos' => [
'type' => 'Txcos'
],
// 更多的磁盘配置信息 // 更多的磁盘配置信息
], ],
]; ];

View File

@@ -0,0 +1,36 @@
<?php
namespace think\filesystem\driver;;
use League\Flysystem\AdapterInterface;
use Qcloud\Cos\Client;
use think\filesystem\Driver;
class Txcos extends Driver
{
protected function createAdapter(): AdapterInterface
{
$secretId = sysconfig('upload', 'txcos_secret_id');
$secretKey = sysconfig('upload', 'txcos_secret_key');
$region = sysconfig('upload', 'txcos_region'); //set a default bucket region 设置一个默认的存储桶地域
$cosClient = new Client(
array(
'region' => $region,
'schema' => 'https', //协议头部默认为http
'credentials' => array(
'secretId' => $secretId,
'secretKey' => $secretKey
),
'signHost' => false
)
);
$bucket = sysconfig('upload', 'tecos_bucket'); //存储桶名称 格式BucketName-APPID
$adapter = new \Chunpat\FlysystemTencentCos\Adapter($cosClient, $bucket);
return $adapter;
}
}