mirror of
https://github.com/filegator/filegator.git
synced 2025-08-01 23:00:19 +02:00
storage config simplified
This commit is contained in:
@@ -26,7 +26,7 @@ class Filesystem implements Service
|
|||||||
$this->separator = $config['separator'];
|
$this->separator = $config['separator'];
|
||||||
$this->path_prefix = $this->separator;
|
$this->path_prefix = $this->separator;
|
||||||
|
|
||||||
$adapter = $config['adapters'][$config['filesystem_adapter']];
|
$adapter = $config['adapter'];
|
||||||
$config = isset($config['config']) ? $config['config'] : [];
|
$config = isset($config['config']) ? $config['config'] : [];
|
||||||
|
|
||||||
$this->storage = new Flysystem($adapter(), $config);
|
$this->storage = new Flysystem($adapter(), $config);
|
||||||
|
@@ -75,16 +75,13 @@ return [
|
|||||||
'config' => [
|
'config' => [
|
||||||
'separator' => '/',
|
'separator' => '/',
|
||||||
'config' => [],
|
'config' => [],
|
||||||
'filesystem_adapter' => 'localfilesystem',
|
'adapter' => function () {
|
||||||
'adapters' => [
|
|
||||||
'localfilesystem' => function () {
|
|
||||||
return new \League\Flysystem\Adapter\Local(
|
return new \League\Flysystem\Adapter\Local(
|
||||||
__DIR__.'/repository'
|
__DIR__.'/repository'
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
|
||||||
'Filegator\Services\Archiver\ArchiverInterface' => [
|
'Filegator\Services\Archiver\ArchiverInterface' => [
|
||||||
'handler' => '\Filegator\Services\Archiver\Adapters\ZipArchiver',
|
'handler' => '\Filegator\Services\Archiver\Adapters\ZipArchiver',
|
||||||
'config' => [],
|
'config' => [],
|
||||||
|
@@ -14,16 +14,13 @@ With default adapter you just need to configure where your ```repository``` fold
|
|||||||
'config' => [
|
'config' => [
|
||||||
'separator' => '/',
|
'separator' => '/',
|
||||||
'config' => [],
|
'config' => [],
|
||||||
'filesystem_adapter' => 'localfilesystem',
|
'adapter' => function () {
|
||||||
'adapters' => [
|
|
||||||
'localfilesystem' => function () {
|
|
||||||
return new \League\Flysystem\Adapter\Local(
|
return new \League\Flysystem\Adapter\Local(
|
||||||
__DIR__.'/repository'
|
__DIR__.'/repository'
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -36,9 +33,7 @@ See official [documentation](https://flysystem.thephpleague.com/docs/adapter/ftp
|
|||||||
'config' => [
|
'config' => [
|
||||||
'separator' => '/',
|
'separator' => '/',
|
||||||
'config' => [],
|
'config' => [],
|
||||||
'filesystem_adapter' => 'ftp',
|
'adapter' => function () {
|
||||||
'adapters' => [
|
|
||||||
'ftp' => function () {
|
|
||||||
return new \League\Flysystem\Adapter\Ftp([
|
return new \League\Flysystem\Adapter\Ftp([
|
||||||
'host' => 'example.com',
|
'host' => 'example.com',
|
||||||
'username' => 'demo',
|
'username' => 'demo',
|
||||||
@@ -49,7 +44,6 @@ See official [documentation](https://flysystem.thephpleague.com/docs/adapter/ftp
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -64,9 +58,7 @@ See official [documentation](https://flysystem.thephpleague.com/docs/adapter/sft
|
|||||||
'config' => [
|
'config' => [
|
||||||
'separator' => '/',
|
'separator' => '/',
|
||||||
'config' => [],
|
'config' => [],
|
||||||
'filesystem_adapter' => 'sftp',
|
'adapter' => function () {
|
||||||
'adapters' => [
|
|
||||||
'sftp' => function () {
|
|
||||||
return new \League\Flysystem\Sftp\SftpAdapter([
|
return new \League\Flysystem\Sftp\SftpAdapter([
|
||||||
'host' => 'example.com',
|
'host' => 'example.com',
|
||||||
'port' => 22,
|
'port' => 22,
|
||||||
@@ -77,7 +69,6 @@ See official [documentation](https://flysystem.thephpleague.com/docs/adapter/sft
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
|
||||||
|
|
||||||
```
|
```
|
||||||
## Dropbox Adapter
|
## Dropbox Adapter
|
||||||
@@ -90,10 +81,10 @@ See official [documentation](https://flysystem.thephpleague.com/docs/adapter/dro
|
|||||||
'handler' => '\Filegator\Services\Storage\Filesystem',
|
'handler' => '\Filegator\Services\Storage\Filesystem',
|
||||||
'config' => [
|
'config' => [
|
||||||
'separator' => '/',
|
'separator' => '/',
|
||||||
'config' => [],
|
'config' => [
|
||||||
'filesystem_adapter' => 'dropbox',
|
'case_sensitive' => false,
|
||||||
'adapters' => [
|
],
|
||||||
'dropbox' => function () {
|
'adapter' => function () {
|
||||||
$authorizationToken = '1234';
|
$authorizationToken = '1234';
|
||||||
$client = new \Spatie\Dropbox\Client($authorizationToken);
|
$client = new \Spatie\Dropbox\Client($authorizationToken);
|
||||||
|
|
||||||
@@ -101,6 +92,5 @@ See official [documentation](https://flysystem.thephpleague.com/docs/adapter/dro
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@@ -41,12 +41,9 @@ class ArchiverTest extends TestCase
|
|||||||
$storage = new Filesystem();
|
$storage = new Filesystem();
|
||||||
$storage->init([
|
$storage->init([
|
||||||
'separator' => '/',
|
'separator' => '/',
|
||||||
'filesystem_adapter' => 'nulladapter',
|
'adapter' => function () {
|
||||||
'adapters' => [
|
|
||||||
'nulladapter' => function () {
|
|
||||||
return new \League\Flysystem\Adapter\NullAdapter();
|
return new \League\Flysystem\Adapter\NullAdapter();
|
||||||
},
|
},
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$uniqid = $this->archiver->createArchive($storage);
|
$uniqid = $this->archiver->createArchive($storage);
|
||||||
@@ -60,12 +57,9 @@ class ArchiverTest extends TestCase
|
|||||||
$storage = new Filesystem();
|
$storage = new Filesystem();
|
||||||
$storage->init([
|
$storage->init([
|
||||||
'separator' => '/',
|
'separator' => '/',
|
||||||
'filesystem_adapter' => 'memoryadapter',
|
'adapter' => function () {
|
||||||
'adapters' => [
|
|
||||||
'memoryadapter' => function () {
|
|
||||||
return new \League\Flysystem\Memory\MemoryAdapter();
|
return new \League\Flysystem\Memory\MemoryAdapter();
|
||||||
},
|
},
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$storage->createDir('/', 'test');
|
$storage->createDir('/', 'test');
|
||||||
@@ -85,12 +79,9 @@ class ArchiverTest extends TestCase
|
|||||||
$storage = new Filesystem();
|
$storage = new Filesystem();
|
||||||
$storage->init([
|
$storage->init([
|
||||||
'separator' => '/',
|
'separator' => '/',
|
||||||
'filesystem_adapter' => 'memoryadapter',
|
'adapter' => function () {
|
||||||
'adapters' => [
|
|
||||||
'memoryadapter' => function () {
|
|
||||||
return new \League\Flysystem\Memory\MemoryAdapter();
|
return new \League\Flysystem\Memory\MemoryAdapter();
|
||||||
},
|
},
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$storage->createDir('/', 'test');
|
$storage->createDir('/', 'test');
|
||||||
@@ -110,12 +101,9 @@ class ArchiverTest extends TestCase
|
|||||||
$storage = new Filesystem();
|
$storage = new Filesystem();
|
||||||
$storage->init([
|
$storage->init([
|
||||||
'separator' => '/',
|
'separator' => '/',
|
||||||
'filesystem_adapter' => 'memoryadapter',
|
'adapter' => function () {
|
||||||
'adapters' => [
|
|
||||||
'memoryadapter' => function () {
|
|
||||||
return new \League\Flysystem\Memory\MemoryAdapter();
|
return new \League\Flysystem\Memory\MemoryAdapter();
|
||||||
},
|
},
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$stream = fopen(TEST_ARCHIVE, 'r');
|
$stream = fopen(TEST_ARCHIVE, 'r');
|
||||||
|
@@ -33,14 +33,11 @@ class FilesystemTest extends TestCase
|
|||||||
$this->storage = new Filesystem();
|
$this->storage = new Filesystem();
|
||||||
$this->storage->init([
|
$this->storage->init([
|
||||||
'separator' => '/',
|
'separator' => '/',
|
||||||
'filesystem_adapter' => 'localfilesystem',
|
'adapter' => function () {
|
||||||
'adapters' => [
|
|
||||||
'localfilesystem' => function () {
|
|
||||||
return new \League\Flysystem\Adapter\Local(
|
return new \League\Flysystem\Adapter\Local(
|
||||||
TEST_REPOSITORY
|
TEST_REPOSITORY
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,16 +52,13 @@ return [
|
|||||||
'handler' => '\Filegator\Services\Storage\Filesystem',
|
'handler' => '\Filegator\Services\Storage\Filesystem',
|
||||||
'config' => [
|
'config' => [
|
||||||
'separator' => '/',
|
'separator' => '/',
|
||||||
'filesystem_adapter' => 'localfilesystem',
|
'adapter' => function () {
|
||||||
'adapters' => [
|
|
||||||
'localfilesystem' => function () {
|
|
||||||
return new \League\Flysystem\Adapter\Local(
|
return new \League\Flysystem\Adapter\Local(
|
||||||
TEST_REPOSITORY
|
TEST_REPOSITORY
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
|
||||||
'Filegator\Services\Auth\AuthInterface' => [
|
'Filegator\Services\Auth\AuthInterface' => [
|
||||||
'handler' => '\Tests\MockUsers',
|
'handler' => '\Tests\MockUsers',
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user