一、按装:composer require overtrue/laravel-filesystem-qiniu
二、配置:
'providers' => [
// Other service providers...
Overtrue\LaravelFilesystem\Qiniu\QiniuStorageServiceProvider::class,
],
三、Add a new disk to your config/filesystems.php config:
<?php
return [
'disks' => [
//...
'qiniu' => [
'driver' => 'qiniu',
'access_key' => env('QINIU_ACCESS_KEY', 'xxxxxxxxxxxxxxxx'),
'secret_key' => env('QINIU_SECRET_KEY', 'xxxxxxxxxxxxxxxx'),
'bucket' => env('QINIU_BUCKET', 'test'),
'domain' => env('QINIU_DOMAIN', 'xxx.clouddn.com'), // or host: https://xxxx.clouddn.com
],
//...
]
];
四、配置env
五、使用
use Storge;
$disk = Storage::disk('qiniu');
$res=\Storage::disk('qiniu')->writeStream($newfile,fopen($file->getRealPath(),'r'));