|
1 |
| -# PHP Package Template |
| 1 | +<div style="text-align: center"> <h1>yii-filesystem-cos</h1> </div> |
2 | 2 |
|
3 |
| -A template repository for PHP package. |
| 3 | +<a href="https://packagist.org/packages/vartruexuan/yii-filesystem-cos" rel="nofollow"><img src="https://badgen.net/github/tag/vartruexuan/yii-filesystem-cos" alt="Latest Version" data-canonical-src="https://badgen.net/github/tag/vartruexuan/yii-filesystem-cos" style="max-width: 100%;"></a> |
| 4 | +<a href="https://www.php.net" rel="nofollow"><img src="https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg?maxAge=2592000" alt="Php Version" data-canonical-src="https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg?maxAge=2592000" style="max-width: 100%;"></a> |
4 | 5 |
|
5 |
| -## Installing |
| 6 | +# 概述 |
| 7 | +[creocoder/yii2-flysystem](https://github.com/creocoder/yii2-flysystem) |
| 8 | + |
| 9 | +# 安装 |
6 | 10 |
|
7 | 11 | ```shell
|
8 |
| -$ composer require vendor/package -vvv |
| 12 | +composer require vartruexuan/yii-filesystem-cos |
9 | 13 | ```
|
10 | 14 |
|
11 |
| -## Usage |
12 |
| - |
13 |
| -TODO |
14 |
| - |
15 |
| - |
16 |
| -## Contributing |
17 |
| - |
18 |
| -You can contribute in one of three ways: |
19 |
| - |
20 |
| -1. File bug reports using the [issue tracker](https://github.com/vendor/package/issues). |
21 |
| -2. Answer questions or fix bugs on the [issue tracker](https://github.com/vendor/package/issues). |
22 |
| -3. Contribute new features or update the wiki. |
23 |
| - |
24 |
| -_The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable._ |
25 |
| - |
26 |
| -## License |
27 |
| - |
28 |
| -MIT |
| 15 | +# 使用 |
| 16 | + |
| 17 | +## 配置组件 |
| 18 | + |
| 19 | +```php |
| 20 | +// 加入配置组件 |
| 21 | +'components' => [ |
| 22 | + 'cos' => [ |
| 23 | + 'class' => 'Vartruexuan\Yii2\Filesystem\Cos\Filesystem', |
| 24 | + // 配置 |
| 25 | + 'region' => 'gz', |
| 26 | + 'appId' => '1272757004', |
| 27 | + 'secretId' => 'AKIDd5HCSPDanlU1ILnzwc2sSmpcIqTY', |
| 28 | + 'secretKey' => '58kxufPxEiiSWIbeuUqxsYzDB3gAPVLwI', |
| 29 | + 'token' => null, |
| 30 | + 'timeout' => 60, |
| 31 | + 'connect_timeout' => 60, |
| 32 | + 'bucket' => 'bucket-1272757004', |
| 33 | + 'cdn' => 'https://bucket-1272757004.file.myqcloud.com', |
| 34 | + 'scheme' => 'https', |
| 35 | + 'read_from_cdn' => false, |
| 36 | + 'cdn_key' => '', |
| 37 | + 'encrypt' => false, |
| 38 | + ], |
| 39 | +], |
| 40 | +``` |
| 41 | +## 使用 |
| 42 | +```php |
| 43 | +bool Yii::$app->cos->->write('file.md', 'contents'); |
| 44 | +bool Yii::$app->cos->->writeStream('file.md', fopen('path/to/your/local/file.jpg', 'r')); |
| 45 | +bool Yii::$app->cos->->update('file.md', 'new contents'); |
| 46 | +bool Yii::$app->cos->->updateStram('file.md', fopen('path/to/your/local/file.jpg', 'r')); |
| 47 | +bool Yii::$app->cos->->rename('foo.md', 'bar.md'); |
| 48 | +bool Yii::$app->cos->->copy('foo.md', 'foo2.md'); |
| 49 | +bool Yii::$app->cos->->delete('file.md'); |
| 50 | +bool Yii::$app->cos->->has('file.md'); |
| 51 | +string|false Yii::$app->cos->->read('file.md'); |
| 52 | +array Yii::$app->cos->->listContents(); |
| 53 | +array Yii::$app->cos->->getMetadata('file.md'); |
| 54 | +int Yii::$app->cos->->getSize('file.md'); |
| 55 | +string Yii::$app->cos->->getUrl('file.md'); |
| 56 | +string Yii::$app->cos->->getTemporaryUrl('file.md', date_create('2018-12-31 18:12:31')); |
| 57 | +string Yii::$app->cos->->getMimetype('file.md'); |
| 58 | +int Yii::$app->cos->->getTimestamp('file.md'); |
| 59 | +string Yii::$app->cos->->getVisibility('file.md'); |
| 60 | +bool Yii::$app->cos->->setVisibility('file.md', 'public'); //or 'private', 'default' |
| 61 | +// ... |
| 62 | +``` |
| 63 | +[详细文档](https://flysystem.thephpleague.com/api/) |
0 commit comments