ThinkPHP6.0 的 filesystem 扩展包支持阿里云 oss 和七牛云

thinkphp-filesystem-cloud

thinkphp6.0 的文件系统扩展包,支持上传阿里云OSS和七牛

包含

  1. php >= 7.1
  2. thinkphp >=6.0.0

支持

  1. 阿里云
  2. 七牛云

计划

  1. 支持腾讯云
  2. 支持华为云

安装

第一步:

$ composer require thans/thinkphp-filesystem-cloud

第二步: 在config/filesystem.php中添加配置

'aliyun' => [
'type' => 'aliyun',
'accessId' => '**',
'accessSecret' => '**',
'bucket' => 'bucket',
'endpoint' => 'oss-cn-hongkong.aliyuncs.com',
'url' => 'http://oss-cn-hongkong.aliyuncs.com',//不要斜杠结尾,此处为URL地址域名
],
'qiniu' => [
'type' => 'qiniu',
'accessKey' => '**',
'secretKey' => '**',
'bucket' => 'bucket',
'url' => '',//不要斜杠结尾,此处为URL地址域名。
],

授权

MIT

感谢

  1. thinkphp
  2. xxtime/flysystem-aliyun-oss
  3. liz/flysystem-qiniu
  4. league/flysystem
Thans
讨论数量: 3

需要在 thans\filesystem\Filesystem 下增加以下方法
/**

  • 获取缓存配置
  • @access public
  • @param null|string $name 名称
  • @param mixed $default 默认值
  • @return mixed
    */
    public function getConfig(string $name = null, $default = null)
    {
    if (!is_null($name)) {
    return $this->app->config->get('filesystem.' . $name, $default);
    }

    return $this->app->config->get('filesystem');

    }

    /**

  • 获取磁盘配置
  • @param string $disk
  • @param null $name
  • @param null $default
  • @return array
    */
    public function getDiskConfig($disk, $name = null, $default = null)
    {
    if ($config = $this->getConfig("disks.{$disk}")) {
    return Arr::get($config, $name, $default);
    }

    throw new InvalidArgumentException("Disk [$disk] not found.");

    }

5年前 评论
Thans (楼主) 5年前

php8 最好也兼容下

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!