Added ability to upload backups via FTP

This commit is contained in:
Pinga 2025-02-03 19:00:48 +02:00
parent e3f5d9f94e
commit 8e943ce1c8
3 changed files with 35 additions and 6 deletions

View file

@ -4,6 +4,8 @@ require __DIR__ . '/vendor/autoload.php';
require_once 'helpers.php';
use League\Flysystem\Filesystem;
use League\Flysystem\Ftp\FtpAdapter;
use League\Flysystem\Ftp\FtpConnectionOptions;
use League\Flysystem\PhpseclibV3\SftpConnectionProvider;
use League\Flysystem\PhpseclibV3\SftpAdapter;
use League\Flysystem\UnixVisibility\PortableVisibilityConverter;
@ -63,6 +65,22 @@ switch ($storageType) {
$adapter = new SftpAdapter($sftpProvider, $sftpSettings['basePath'], $visibilityConverter);
break;
case 'ftp':
$ftpSettings = $config['ftp'];
$connectionOptions = FtpConnectionOptions::fromArray([
'host' => $ftpSettings['host'],
'username' => $ftpSettings['username'],
'password' => $ftpSettings['password'],
'port' => $ftpSettings['port'] ?? 21,
'root' => $ftpSettings['basePath'] ?? '/',
'passive' => $ftpSettings['passive'] ?? true,
'ssl' => $ftpSettings['ssl'] ?? false,
'timeout' => $ftpSettings['timeout'] ?? 30,
]);
$adapter = new FtpAdapter($connectionOptions);
break;
case 'dropbox':
$dropboxSettings = $config['dropbox'];
$client = new \Spatie\Dropbox\Client($dropboxSettings['accessToken']);