jiangyunan / flysystem by jiangyunan

Laravel 文件管理的OSS扩展
12
1
2
Package Data
Maintainer Username: jiangyunan
Maintainer Contact: jiang_yun_an@qq.com (Jiangyunan)
Package Create Date: 2016-12-15
Package Last Update: 2016-12-15
Language: PHP
License: MIT
Last Refreshed: 2024-04-17 15:06:52
Package Statistics
Total Downloads: 12
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

#使用说明 目前只支持普通上传

###配置

//filesystem.php
'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => 'your-key',
            'secret' => 'your-secret',
            'region' => 'your-region',
            'bucket' => 'your-bucket',
        ],

        'oss' => [
            'driver' => 'oss',
            'accessKeyId' => 'xxxx',
            'accessKeySecret' => 'xxxx',
            'endpoint' => 'xxxx',
            'bucket' => 'xxxx'
        ]

    ],

###注册服务容器

namespace App\Providers;

use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use Jiangyunan\Flysystem\Adapter\OssAdapter;
use League\Flysystem\Filesystem;
use OSS\OssClient;

class OssServiceProvider extends ServiceProvider
{
    public function boot()
    {
        Storage::extend('oss', function($app, $config){
            $client = new OssClient($config['accessKeyId'], $config['accessKeySecret'], $config['endpoint']);
            return new Filesystem(new OssAdapter($client, $config['bucket']));
        });
    }

    public function register()
    {
        //
    }
}