vartruexuan/yii-filesystem-cos

yii2 filesystem 腾讯云cos

1.0.1 2023-03-10 01:57 UTC

This package is auto-updated.

Last update: 2024-10-12 05:16:06 UTC


README

yii-filesystem-cos

Latest Version Php Version

概述

creocoder/yii2-flysystem

安装

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'
// ...

详细文档