初始化
This commit is contained in:
45
addons/webman/filesystem/driver/Oss.php
Normal file
45
addons/webman/filesystem/driver/Oss.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace addons\webman\filesystem\driver;
|
||||
|
||||
|
||||
use addons\webman\filesystem\AdapterFactoryInterface;
|
||||
use Iidestiny\Flysystem\Oss\OssAdapter;
|
||||
use Iidestiny\Flysystem\Oss\Plugins\FileUrl;
|
||||
use Iidestiny\Flysystem\Oss\Plugins\Kernel;
|
||||
use Iidestiny\Flysystem\Oss\Plugins\SetBucket;
|
||||
use Iidestiny\Flysystem\Oss\Plugins\SignatureConfig;
|
||||
use Iidestiny\Flysystem\Oss\Plugins\SignUrl;
|
||||
use Iidestiny\Flysystem\Oss\Plugins\TemporaryUrl;
|
||||
use Iidestiny\Flysystem\Oss\Plugins\Verify;
|
||||
use League\Flysystem\Filesystem;
|
||||
|
||||
class Oss implements AdapterFactoryInterface
|
||||
{
|
||||
|
||||
public function make(array $options)
|
||||
{
|
||||
$root = $options['root'] ?? null;
|
||||
$buckets = isset($options['buckets'])?$options['buckets']:[];
|
||||
$adapter = new OssAdapter(
|
||||
$options['access_key'],
|
||||
$options['secret_key'],
|
||||
$options['endpoint'],
|
||||
$options['bucket'],
|
||||
$options['isCName'],
|
||||
$root,
|
||||
$buckets
|
||||
);
|
||||
$filesystem = new Filesystem($adapter);
|
||||
|
||||
$filesystem->addPlugin(new FileUrl());
|
||||
$filesystem->addPlugin(new SignUrl());
|
||||
$filesystem->addPlugin(new TemporaryUrl());
|
||||
$filesystem->addPlugin(new SignatureConfig());
|
||||
$filesystem->addPlugin(new SetBucket());
|
||||
$filesystem->addPlugin(new Verify());
|
||||
$filesystem->addPlugin(new Kernel());
|
||||
return $filesystem;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user