panwenbin/yii2-aliyunoss

Yii2 component for aliyun oss

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

0.1.1 2018-06-12 09:30 UTC

This package is not auto-updated.

Last update: 2024-11-08 12:56:31 UTC


README

大部分情况我们程序只是使用OSS的存储功能,对于bucket管理用的比较少
所以对常用的部分做了封装,减少了bucket参数传递,处理了异常(异常时返回null)

在Yii2中使用

在配置文件增加

return [
    'components' => [
        'oss' => [
            'class' => 'panwenbin\yii2\aliyunoss\OssBucket',
            'endPoint' => 'oss-cn-shanghai.aliyuncs.com',
            'accessKeyId' => 'abcdefghijklmn',
            'accessKeySecret' => '1234567890',
            'bucket' => 'panwenbin',
            'cname' => 'oss.panwenbin.com',
        ],
    ],
];

使用

$oss = Yii::$app->get('oss');
$isSuccess = $oss->putObject('somefile.txt', 'This is a test file!');