jiangyunan / flysystem
Laravel 文件管理的OSS扩展
dev-master
2016-12-15 08:52 UTC
Requires
- php: >=5.5.9
- aliyuncs/oss-sdk-php: *
- league/flysystem: *
This package is auto-updated.
Last update: 2024-11-18 18:43:55 UTC
README
#使用说明 目前只支持普通上传
###配置
//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()
{
//
}
}