mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-06 01:52:48 +08:00
开始腾讯提交;
This commit is contained in:
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