vartruexuan / yii-filesystem-cos
yii2 filesystem 腾讯云cos
Fund package maintenance!
vartruexuan
1.0.1
2023-03-10 01:57 UTC
Requires
- php: >=7.4
- creocoder/yii2-flysystem: ^1.1
- freyo/flysystem-qcloud-cos-v5: ^2.2
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.8
- friendsofphp/php-cs-fixer: ^3.0
- jetbrains/phpstorm-attributes: ^1.0
- mockery/mockery: ^1.2
- phpunit/phpunit: ^9.0
- vimeo/psalm: ^4.10
README
yii-filesystem-cos
概述
安装
composer require vartruexuan/yii-filesystem-cos
使用
配置组件
// 加入配置组件 'components' => [ 'cos' => [ 'class' => 'Vartruexuan\Yii2\Filesystem\Cos\Filesystem', // 配置 'region' => 'gz', 'appId' => '1272757004', 'secretId' => 'AKIDd5HCSPDanlU1ILnzwc2sSmpcIqTY', 'secretKey' => '58kxufPxEiiSWIbeuUqxsYzDB3gAPVLwI', 'token' => null, 'timeout' => 60, 'connect_timeout' => 60, 'bucket' => 'bucket-1272757004', 'cdn' => 'https://bucket-1272757004.file.myqcloud.com', 'scheme' => 'https', 'read_from_cdn' => false, 'cdn_key' => '', 'encrypt' => false, ], ],
使用
bool Yii::$app->cos->->write('file.md', 'contents'); bool Yii::$app->cos->->writeStream('file.md', fopen('path/to/your/local/file.jpg', 'r')); bool Yii::$app->cos->->update('file.md', 'new contents'); bool Yii::$app->cos->->updateStram('file.md', fopen('path/to/your/local/file.jpg', 'r')); bool Yii::$app->cos->->rename('foo.md', 'bar.md'); bool Yii::$app->cos->->copy('foo.md', 'foo2.md'); bool Yii::$app->cos->->delete('file.md'); bool Yii::$app->cos->->has('file.md'); string|false Yii::$app->cos->->read('file.md'); array Yii::$app->cos->->listContents(); array Yii::$app->cos->->getMetadata('file.md'); int Yii::$app->cos->->getSize('file.md'); string Yii::$app->cos->->getUrl('file.md'); string Yii::$app->cos->->getTemporaryUrl('file.md', date_create('2018-12-31 18:12:31')); string Yii::$app->cos->->getMimetype('file.md'); int Yii::$app->cos->->getTimestamp('file.md'); string Yii::$app->cos->->getVisibility('file.md'); bool Yii::$app->cos->->setVisibility('file.md', 'public'); //or 'private', 'default' // ...