# thinkphp-filesystem-cloud **Repository Path**: XY-JX/thinkphp-filesystem-cloud ## Basic Information - **Project Name**: thinkphp-filesystem-cloud - **Description**: thinkphp6.0 的文件系统扩展包,支持上传阿里云OSS和七牛和腾讯云COS - **Primary Language**: PHP - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 1 - **Created**: 2021-08-09 - **Last Updated**: 2023-04-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: thinkphp6, 阿里云OSS, 腾讯云COS, 七牛云 ## README
thinkphp-filesystem-cloud
thinkphp6.0 的文件系统扩展包,支持上传阿里云OSS和七牛和腾讯云COS
## 包含 1. php >= 7.1 2. thinkphp >=6.0.0 3. guzzlehttp/guzzle >= 7 ## 支持 1. 阿里云 2. 七牛云 3. 腾讯云 ## 版本说明 v1. guzzlehttp/guzzle 支持 6.* ```shell $ composer require xy_jx/thinkphp-filesystem-cloud 1.1.* ``` v2. guzzlehttp/guzzle 支持 7.* ```shell $ composer require xy_jx/thinkphp-filesystem-cloud ``` 所使用扩展有所不同 ## 安装 第一步: ```shell $ composer require xy_jx/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地址域名。 ], 'qcloud' => [ 'type' => 'qcloud', 'region' => '***', //bucket 所属区域 英文 'appId' => '***', // 域名中数字部分 'secretId' => '***', 'secretKey' => '***', 'bucket' => '***', 'timeout' => 60, 'connect_timeout' => 60, 'cdn' => '您的 CDN 域名', 'scheme' => 'http', 'read_from_cdn' => false, ] ``` 第三步: 开始使用。 ``` file('file'); if ($file) { //验证文件 $this->validate($request->file(), ['file' => 'fileSize:10485760|fileMime:image/jpeg,image/png|file']); // 上传到阿里云oss $savename = Filesystem::disk('aliyun')->putFile('', $file); $result = [ 'type' => $file->getMime(), 'extension' => $file->extension(), 'url' => $savename, 'full_url' => $type['url'] . $savename, ]; return \Api::success($result); } else { return \Api::error('没有上传文件'); } } } ``` 请参考thinkphp文档 文档地址:[https://www.kancloud.cn/manual/thinkphp6_0/1037639 ](https://www.kancloud.cn/manual/thinkphp6_0/1037639 ) ## 授权 MIT ## 感谢 1. thinkphp 2. xxtime/flysystem-aliyun-oss 3. liz/flysystem-qiniu 4. league/flysystem 5. overtrue/flysystem-cos