mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
开始腾讯提交;
This commit is contained in:
@@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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...
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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
39
composer.lock
generated
@@ -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",
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ return [
|
|||||||
'alioss' => [
|
'alioss' => [
|
||||||
'type' => 'Alioss'
|
'type' => 'Alioss'
|
||||||
],
|
],
|
||||||
|
'txcos' => [
|
||||||
|
'type' => 'Txcos'
|
||||||
|
],
|
||||||
// 更多的磁盘配置信息
|
// 更多的磁盘配置信息
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
36
extend/think/filesystem/driver/Txcos.php
Normal file
36
extend/think/filesystem/driver/Txcos.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user