liuwave/think-filesystem-driver-cos

这是一个基于腾讯云对象存储的thinkphp6.0 Filesystem驱动

v0.0.1 2020-07-06 12:18 UTC

This package is auto-updated.

Last update: 2024-03-08 09:51:40 UTC


README

这是一个基于腾讯云对象存储的thinkphp6.0 Filesystem驱动。

安装

    composer require liuwave/think-filesystem-driver-cos

config/filesystem.php中添加配置:

    'cos' => [
      'type'            => \liuwave\filesystem\driver\Cos::class ,
      'region'          => '***', //bucket 所属区域 英文
      'appId'           => '***', // 域名中数字部分
      'secretId'        => '***',
      'secretKey'       => '***',
      'bucket'          => '***',
      'timeout'         => 60,
      'connect_timeout' => 60,
      'cdn'             => '您的 CDN 域名',
      'scheme'          => 'https',
      'read_from_cdn'   => false,
      'url'       => '',//访问域名
    ],

使用

//默认$file为单文件。$file为多文件时file为数组,需要进行遍历处理
$file=\request()->file('file');
$filesystem     = \think\facade\Filesystem::disk('cos');
$saveName       = $filesystem->putFile('/path/to/save/file', $file, 'md5');
$saveName       = str_replace('\\', '/', $saveName);
$fullName = \think\facade\Filesystem::getDiskConfig('cos', 'url').'/'.$saveName;

授权

MIT

参考

更多