aiddroid / flysystem-qiniu

Flysystem适配器,用于Qiniu PHP SDK v7

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

This package is auto-updated.

Last update: 2024-09-13 15:54:47 UTC


README

Flysystem适配器,用于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');