Files
filegator/docs/configuration/storage.md
Milos Stojanovic f8940c8713 docs upd
2019-06-18 14:27:31 +02:00

3.6 KiB

Adapters

Different storage adapters are supported via awesome Flysystem library.

You can use local filesystem (default), FTP, S3, Dropbox and many others. Please check Flysystem for exact setup for each adapter.

Default Local Disk Adapter

With default adapter you just need to configure where is you repository folder which will serve as root for everything else.

        'Filegator\Services\Storage\Filesystem' => [
            'handler' => '\Filegator\Services\Storage\Filesystem',
            'config' => [
                'separator' => '/',
                'config' => [],
                'filesystem_adapter' => 'localfilesystem',
                'adapters' => [
                    'localfilesystem' => function () {
                        return new \League\Flysystem\Adapter\Local(
                            __DIR__.'/repository'
                        );
                    },
                ],
            ],
        ],

FTP Adapter

See official documentation

        'Filegator\Services\Storage\Filesystem' => [
            'handler' => '\Filegator\Services\Storage\Filesystem',
            'config' => [
                'separator' => '/',
                'config' => [],
                'filesystem_adapter' => 'ftp',
                'adapters' => [
                    'ftp' => function () {
                        return new \League\Flysystem\Adapter\Ftp([
                            'host' => 'example.com',
                            'username' => 'demo',
                            'password' => 'password',
                            'port' => 21,
                            'timeout' => 10,
                        ]);
                    },
                ],
            ],
        ],

SFTP Adapter

You must require additional library composer require league/flysystem-sftp. See official documentation.

        'Filegator\Services\Storage\Filesystem' => [
            'handler' => '\Filegator\Services\Storage\Filesystem',
            'config' => [
                'separator' => '/',
                'config' => [],
                'filesystem_adapter' => 'sftp',
                'adapters' => [
                    'sftp' => function () {
                        return new \League\Flysystem\Sftp\SftpAdapter([
                            'host' => 'example.com',
                            'port' => 22,
                            'username' => 'demo',
                            'password' => 'password',
                            'timeout' => 10,
                        ]);
                    },
                ],
            ],
        ],

Dropbox Adapter

You must require additional library composer require spatie/flysystem-dropbox. See official documentation

        'Filegator\Services\Storage\Filesystem' => [
            'handler' => '\Filegator\Services\Storage\Filesystem',
            'config' => [
                'separator' => '/',
                'config' => [],
                'filesystem_adapter' => 'dropbox',
                'adapters' => [
                    'dropbox' => function () {
                        $authorizationToken = '1234';
                        $client = new \Spatie\Dropbox\Client($authorizationToken);

                        return new \Spatie\FlysystemDropbox\DropboxAdapter($client);
                    },
                ],
            ],
        ],