aiddroid/flysystem-qiniu

Flysystem adapter for Qiniu PHP SDK v7

dev-master 2015-12-18 02:47 UTC

This package is auto-updated.

Last update: 2024-11-13 16:07:10 UTC


README

Flysystem Adapter for Qiniu sdk v7.x

安装

  • 通过composer,这是推荐的方式,可以使用composer.json 声明依赖,或者运行下面的命令。
$ composer require aiddroid/flysystem-qiniu

Yii2配置config/web.php

  'components' => [
        //...
        'fileStorage' => [
            'class' => '\trntv\filekit\Storage',
            'baseUrl' => '@storageUrl/source',
            'filesystem' => [
                'class' => '\aiddroid\flysystem\qiniu\QiniuFlysystemBuilder',
                'accessKey' => 'testAccessKey',//Qiniu的配置参数 http://www.qiniu.com/
                'secretKey' => 'testSecretKey',
                'bucketName' => 'testbucket',
            ]
        ],
        //...

Yii2用法

$uploadedFile = \yii\web\UploadedFile::getInstance($uploadForm, 'avatarFile');
Yii::$app->fileStorage->save($uploadedFile);

一般用法

use aiddroid\flysystem\qiniu\QiniuAdapter;
$adapter = new QiniuAdapter($accessKey, $secretKey,$bucketName);
$adapter->write('filepath','contents');