Skip to content

Commit

Permalink
Add integration with B2 Cloud (#51)
Browse files Browse the repository at this point in the history
* Add integration with B2 Cloud

* Use 1.3
  • Loading branch information
InnerFlameFact authored and Nyholm committed Dec 19, 2018
1 parent 801e523 commit a4d0bf3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions DependencyInjection/BMBackupManagerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use League\Flysystem\Adapter\Local;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Dropbox\DropboxAdapter;
use Mhetreramesh\Flysystem\BackblazeAdapter;
use Srmklive\Dropbox\Adapter\DropboxAdapter as Dropbox2Adapter;
use League\Flysystem\Rackspace\RackspaceAdapter;
use League\Flysystem\Sftp\SftpAdapter;
Expand Down Expand Up @@ -34,6 +35,7 @@ public function load(array $configs, ContainerBuilder $container)
$managerIdMap = [
'Local' => 'backup_manager.filesystems.local_filesystem',
'AwsS3' => 'backup_manager.filesystems.awss3_filesystem',
'B2' => 'backup_manager.filesystems.b2_filesystem',
'Rackspace' => 'backup_manager.filesystems.rackspace_filesystem',
'Dropbox' => 'backup_manager.filesystems.dropbox_filesystem',
'DropboxV2' => 'backup_manager.filesystems.dropbox_v2_filesystem',
Expand Down Expand Up @@ -67,6 +69,7 @@ private function validateStorage(array $config)
$requirements = [
'Local' => ['package'=>'league/flysystem:^1.0', 'test'=>Local::class],
'AwsS3' => ['package'=>'league/flysystem-aws-s3-v3:^1.0', 'test'=>AwsS3Adapter::class],
'B2' => ['package'=>'mhetreramesh/flysystem-backblaze:^1.0', 'test'=>BackblazeAdapter::class],
'Rackspace' => ['package'=>'league/flysystem-rackspace:^1.0', 'test'=>RackspaceAdapter::class],
'Dropbox' => ['package'=>'league/flysystem-dropbox:^1.0', 'test'=>DropboxAdapter::class],
'DropboxV2' => ['package'=>'srmklive/flysystem-dropbox-v2:^1.0', 'test'=>Dropbox2Adapter::class],
Expand Down
5 changes: 4 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public function getConfigTreeBuilder()
case 'AwsS3':
$this->validateAuthenticationType(['key', 'secret', 'region', 'version', 'bucket', 'root'], $config, 'AwsS3');
break;
case 'B2':
$this->validateAuthenticationType(['key', 'accountId', 'bucket'], $config, 'B2');
break;
case 'Rackspace':
$this->validateAuthenticationType(['username', 'password', 'container'], $config, 'Rackspace');
break;
Expand All @@ -55,7 +58,7 @@ public function getConfigTreeBuilder()
$this->validateAuthenticationType(['host', 'username', 'password', 'root', 'port', 'timeout', 'privateKey'], $config, 'Sftp');
break;
default:
$validTypes = ['Local', 'AwsS3', 'Rackspace', 'Dropbox', 'DropboxV2', 'Ftp', 'Sftp'];
$validTypes = ['Local', 'AwsS3', 'B2', 'Rackspace', 'Dropbox', 'DropboxV2', 'Ftp', 'Sftp'];
throw new InvalidConfigurationException(sprintf('Type must be one of "%s", got "%s"', implode(', ', $validTypes), $config['type']));
}
}
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ bm_backup_manager:
version: latest
bucket:
root:
b2:
type: B2
key:
accountId:
bucket:
rackspace:
type: Rackspace
username:
Expand Down
4 changes: 4 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ services:
class: BackupManager\Filesystems\Awss3Filesystem
public: false

backup_manager.filesystems.b2_filesystem:
class: BackupManager\Filesystems\BackblazeFilesystem
public: false

backup_manager.filesystems.dropbox_filesystem:
class: BackupManager\Filesystems\DropboxFilesystem
public: false
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function testStorageTypes($type)
public function validStorageTypes()
{
return [
['Local'],['AwsS3'], ['Rackspace'], ['Dropbox'], ['DropboxV2'], ['Ftp'], ['Sftp'],
['Local'],['AwsS3'], ['B2'], ['Rackspace'], ['Dropbox'], ['DropboxV2'], ['Ftp'], ['Sftp'],
];
}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"require": {
"php": "^5.5 || ^7.0",
"backup-manager/backup-manager": "^1.2",
"backup-manager/backup-manager": "^1.3",
"nyholm/dsn": "^0.1",
"symfony/config": "^2.7 || ^3.1 || ^4.0",
"symfony/console": "^2.7 || ^3.1 || ^4.0",
Expand All @@ -30,6 +30,7 @@
},
"suggest": {
"league/flysystem-aws-s3-v3": "To use AWS S3, version 3",
"mhetreramesh/flysystem-backblaze": "To use B2",
"srmklive/flysystem-dropbox-v2": "To use Dropbox",
"league/flysystem-rackspace": "To use Rackspace",
"league/flysystem-sftp": "To use sftp"
Expand Down

0 comments on commit a4d0bf3

Please sign in to comment.