mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 03:37:44 +08:00
Added flysystem-cos for hyperf/filesystem
(#2097)
* Added flysystem-cos for `hyperf/filesystem` * Update CHANGELOG-2.0.md Co-authored-by: 李铭昕 <715557344@qq.com>
This commit is contained in:
parent
6f45957814
commit
2b143cf1ca
@ -1,5 +1,9 @@
|
|||||||
# v2.0.3 - TBD
|
# v2.0.3 - TBD
|
||||||
|
|
||||||
|
## Added
|
||||||
|
|
||||||
|
- [#2097](https://github.com/hyperf/hyperf/pull/2097) Added TencentCloud COS for `hyperf/filesystem`.
|
||||||
|
|
||||||
# v2.0.2 - 2020-07-13
|
# v2.0.2 - 2020-07-13
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
@ -63,6 +63,7 @@
|
|||||||
"nikic/fast-route": "^1.3",
|
"nikic/fast-route": "^1.3",
|
||||||
"nikic/php-parser": "^4.1",
|
"nikic/php-parser": "^4.1",
|
||||||
"overtrue/flysystem-qiniu": "^1.0",
|
"overtrue/flysystem-qiniu": "^1.0",
|
||||||
|
"overtrue/flysystem-cos": "^2.0",
|
||||||
"php-amqplib/php-amqplib": "^2.7",
|
"php-amqplib/php-amqplib": "^2.7",
|
||||||
"php-di/php-di": "^6.0",
|
"php-di/php-di": "^6.0",
|
||||||
"php-di/phpdoc-reader": "^2.0.1",
|
"php-di/phpdoc-reader": "^2.0.1",
|
||||||
|
@ -16,6 +16,8 @@ composer require hyperf/guzzle
|
|||||||
composer require overtrue/flysystem-qiniu
|
composer require overtrue/flysystem-qiniu
|
||||||
# 使用内存适配器时执行
|
# 使用内存适配器时执行
|
||||||
composer require league/flysystem-memory
|
composer require league/flysystem-memory
|
||||||
|
# 使用腾讯云 COS 适配器时执行
|
||||||
|
composer require overtrue/flysystem-cos
|
||||||
```
|
```
|
||||||
|
|
||||||
安装完成后,执行
|
安装完成后,执行
|
||||||
@ -128,7 +130,7 @@ return [
|
|||||||
|
|
||||||
## 注意事项
|
## 注意事项
|
||||||
|
|
||||||
1. S3 存储请确认安装 `hyperf/guzzle` 组件以提供协程化支持。阿里云、七牛云存储请[开启 Curl Hook](/zh-cn/coroutine?id=swoole-runtime-hook-level)来使用协程。因 Curl Hook 的参数支持性问题,请使用 Swoole 4.4.13 以上版本。
|
1. S3 存储请确认安装 `hyperf/guzzle` 组件以提供协程化支持。阿里云、七牛云、腾讯云云存储请[开启 Curl Hook](/zh-cn/coroutine?id=swoole-runtime-hook-level)来使用协程。因 Curl Hook 的参数支持性问题,请使用 Swoole 4.4.13 以上版本。
|
||||||
2. minIO, ceph radosgw 等私有对象存储方案均支持 S3 协议,可以使用 S3 适配器。
|
2. minIO, ceph radosgw 等私有对象存储方案均支持 S3 协议,可以使用 S3 适配器。
|
||||||
3. 使用 Local 驱动时,根目录是配置好的地址,而不是操作系统的根目录。例如,Local 驱动 `root` 设置为 `/var/www`, 则本地磁盘上的 `/var/www/public/file.txt` 通过 flysystem API 访问时应使用 `/public/file.txt` 或 `public/file.txt` 。
|
3. 使用 Local 驱动时,根目录是配置好的地址,而不是操作系统的根目录。例如,Local 驱动 `root` 设置为 `/var/www`, 则本地磁盘上的 `/var/www/public/file.txt` 通过 flysystem API 访问时应使用 `/public/file.txt` 或 `public/file.txt` 。
|
||||||
4. 以阿里云 OSS 为例,1 核 1 进程读操作性能对比:
|
4. 以阿里云 OSS 为例,1 核 1 进程读操作性能对比:
|
||||||
@ -241,6 +243,21 @@ return [
|
|||||||
'bucket' => env('QINIU_BUCKET'),
|
'bucket' => env('QINIU_BUCKET'),
|
||||||
'domain' => env('QINIU_DOMAIN'),
|
'domain' => env('QINIU_DOMAIN'),
|
||||||
],
|
],
|
||||||
|
'cos' => [
|
||||||
|
'driver' => \Hyperf\Filesystem\Adapter\CosAdapterFactory::class,
|
||||||
|
'region' => env('COS_REGION'),
|
||||||
|
'credentials' => [
|
||||||
|
'appId' => env('COS_APPID'),
|
||||||
|
'secretId' => env('COS_SECRET_ID'),
|
||||||
|
'secretKey' => env('COS_SECRET_KEY'),
|
||||||
|
],
|
||||||
|
'bucket' => env('COS_BUCKET'),
|
||||||
|
'read_from_cdn' => false,
|
||||||
|
// 'timeout' => 60,
|
||||||
|
// 'connect_timeout' => 60,
|
||||||
|
// 'cdn' => '',
|
||||||
|
// 'scheme' => 'https',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
"league/flysystem-aws-s3-v3": "^1.0",
|
"league/flysystem-aws-s3-v3": "^1.0",
|
||||||
"league/flysystem-memory": "^1.0",
|
"league/flysystem-memory": "^1.0",
|
||||||
"overtrue/flysystem-qiniu": "^1.0",
|
"overtrue/flysystem-qiniu": "^1.0",
|
||||||
|
"overtrue/flysystem-cos": "^2.0",
|
||||||
"phpstan/phpstan": "^0.10.5",
|
"phpstan/phpstan": "^0.10.5",
|
||||||
"xxtime/flysystem-aliyun-oss": "^1.5"
|
"xxtime/flysystem-aliyun-oss": "^1.5"
|
||||||
},
|
},
|
||||||
@ -42,7 +43,8 @@
|
|||||||
"league/flysystem-memory": "required to use memory adapter",
|
"league/flysystem-memory": "required to use memory adapter",
|
||||||
"hyperf/guzzle": "required to use s3 adapter",
|
"hyperf/guzzle": "required to use s3 adapter",
|
||||||
"league/flysystem-aws-s3-v3": "required to use s3 adapter",
|
"league/flysystem-aws-s3-v3": "required to use s3 adapter",
|
||||||
"overtrue/flysystem-qiniu": "required to use qiniu adapter"
|
"overtrue/flysystem-qiniu": "required to use qiniu adapter",
|
||||||
|
"overtrue/flysystem-cos": "required to use cos adapter"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"sort-packages": true
|
"sort-packages": true
|
||||||
|
@ -75,5 +75,20 @@ return [
|
|||||||
'bucket' => env('QINIU_BUCKET'),
|
'bucket' => env('QINIU_BUCKET'),
|
||||||
'domain' => env('QINBIU_DOMAIN'),
|
'domain' => env('QINBIU_DOMAIN'),
|
||||||
],
|
],
|
||||||
|
'cos' => [
|
||||||
|
'driver' => \Hyperf\Filesystem\Adapter\CosAdapterFactory::class,
|
||||||
|
'region' => env('COS_REGION'),
|
||||||
|
'credentials' => [
|
||||||
|
'appId' => env('COS_APPID'),
|
||||||
|
'secretId' => env('COS_SECRET_ID'),
|
||||||
|
'secretKey' => env('COS_SECRET_KEY'),
|
||||||
|
],
|
||||||
|
'bucket' => env('COS_BUCKET'),
|
||||||
|
'read_from_cdn' => false,
|
||||||
|
// 'timeout' => 60,
|
||||||
|
// 'connect_timeout' => 60,
|
||||||
|
// 'cdn' => '',
|
||||||
|
// 'scheme' => 'https',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
24
src/filesystem/src/Adapter/CosAdapterFactory.php
Normal file
24
src/filesystem/src/Adapter/CosAdapterFactory.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
/**
|
||||||
|
* This file is part of Hyperf.
|
||||||
|
*
|
||||||
|
* @link https://www.hyperf.io
|
||||||
|
* @document https://doc.hyperf.io
|
||||||
|
* @contact group@hyperf.io
|
||||||
|
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
namespace Hyperf\Filesystem\Adapter;
|
||||||
|
|
||||||
|
use Hyperf\Filesystem\Contract\AdapterFactoryInterface;
|
||||||
|
use League\Flysystem\AdapterInterface;
|
||||||
|
use Overtrue\Flysystem\Cos\CosAdapter;
|
||||||
|
|
||||||
|
class CosAdapterFactory implements AdapterFactoryInterface
|
||||||
|
{
|
||||||
|
public function make(array $options): AdapterInterface
|
||||||
|
{
|
||||||
|
return new CosAdapter($options);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user