Skip to content

Commit a4d0bf3

Browse files
InnerFlameFactNyholm
authored andcommitted
Add integration with B2 Cloud (#51)
* Add integration with B2 Cloud * Use 1.3
1 parent 801e523 commit a4d0bf3

File tree

6 files changed

+19
-3
lines changed

6 files changed

+19
-3
lines changed

DependencyInjection/BMBackupManagerExtension.php

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use League\Flysystem\Adapter\Local;
77
use League\Flysystem\AwsS3v3\AwsS3Adapter;
88
use League\Flysystem\Dropbox\DropboxAdapter;
9+
use Mhetreramesh\Flysystem\BackblazeAdapter;
910
use Srmklive\Dropbox\Adapter\DropboxAdapter as Dropbox2Adapter;
1011
use League\Flysystem\Rackspace\RackspaceAdapter;
1112
use League\Flysystem\Sftp\SftpAdapter;
@@ -34,6 +35,7 @@ public function load(array $configs, ContainerBuilder $container)
3435
$managerIdMap = [
3536
'Local' => 'backup_manager.filesystems.local_filesystem',
3637
'AwsS3' => 'backup_manager.filesystems.awss3_filesystem',
38+
'B2' => 'backup_manager.filesystems.b2_filesystem',
3739
'Rackspace' => 'backup_manager.filesystems.rackspace_filesystem',
3840
'Dropbox' => 'backup_manager.filesystems.dropbox_filesystem',
3941
'DropboxV2' => 'backup_manager.filesystems.dropbox_v2_filesystem',
@@ -67,6 +69,7 @@ private function validateStorage(array $config)
6769
$requirements = [
6870
'Local' => ['package'=>'league/flysystem:^1.0', 'test'=>Local::class],
6971
'AwsS3' => ['package'=>'league/flysystem-aws-s3-v3:^1.0', 'test'=>AwsS3Adapter::class],
72+
'B2' => ['package'=>'mhetreramesh/flysystem-backblaze:^1.0', 'test'=>BackblazeAdapter::class],
7073
'Rackspace' => ['package'=>'league/flysystem-rackspace:^1.0', 'test'=>RackspaceAdapter::class],
7174
'Dropbox' => ['package'=>'league/flysystem-dropbox:^1.0', 'test'=>DropboxAdapter::class],
7275
'DropboxV2' => ['package'=>'srmklive/flysystem-dropbox-v2:^1.0', 'test'=>Dropbox2Adapter::class],

DependencyInjection/Configuration.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public function getConfigTreeBuilder()
3939
case 'AwsS3':
4040
$this->validateAuthenticationType(['key', 'secret', 'region', 'version', 'bucket', 'root'], $config, 'AwsS3');
4141
break;
42+
case 'B2':
43+
$this->validateAuthenticationType(['key', 'accountId', 'bucket'], $config, 'B2');
44+
break;
4245
case 'Rackspace':
4346
$this->validateAuthenticationType(['username', 'password', 'container'], $config, 'Rackspace');
4447
break;
@@ -55,7 +58,7 @@ public function getConfigTreeBuilder()
5558
$this->validateAuthenticationType(['host', 'username', 'password', 'root', 'port', 'timeout', 'privateKey'], $config, 'Sftp');
5659
break;
5760
default:
58-
$validTypes = ['Local', 'AwsS3', 'Rackspace', 'Dropbox', 'DropboxV2', 'Ftp', 'Sftp'];
61+
$validTypes = ['Local', 'AwsS3', 'B2', 'Rackspace', 'Dropbox', 'DropboxV2', 'Ftp', 'Sftp'];
5962
throw new InvalidConfigurationException(sprintf('Type must be one of "%s", got "%s"', implode(', ', $validTypes), $config['type']));
6063
}
6164
}

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ bm_backup_manager:
9595
version: latest
9696
bucket:
9797
root:
98+
b2:
99+
type: B2
100+
key:
101+
accountId:
102+
bucket:
98103
rackspace:
99104
type: Rackspace
100105
username:

Resources/config/services.yml

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ services:
2222
class: BackupManager\Filesystems\Awss3Filesystem
2323
public: false
2424

25+
backup_manager.filesystems.b2_filesystem:
26+
class: BackupManager\Filesystems\BackblazeFilesystem
27+
public: false
28+
2529
backup_manager.filesystems.dropbox_filesystem:
2630
class: BackupManager\Filesystems\DropboxFilesystem
2731
public: false

Tests/Unit/DependencyInjection/ConfigurationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function testStorageTypes($type)
176176
public function validStorageTypes()
177177
{
178178
return [
179-
['Local'],['AwsS3'], ['Rackspace'], ['Dropbox'], ['DropboxV2'], ['Ftp'], ['Sftp'],
179+
['Local'],['AwsS3'], ['B2'], ['Rackspace'], ['Dropbox'], ['DropboxV2'], ['Ftp'], ['Sftp'],
180180
];
181181
}
182182
}

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"require": {
1414
"php": "^5.5 || ^7.0",
15-
"backup-manager/backup-manager": "^1.2",
15+
"backup-manager/backup-manager": "^1.3",
1616
"nyholm/dsn": "^0.1",
1717
"symfony/config": "^2.7 || ^3.1 || ^4.0",
1818
"symfony/console": "^2.7 || ^3.1 || ^4.0",
@@ -30,6 +30,7 @@
3030
},
3131
"suggest": {
3232
"league/flysystem-aws-s3-v3": "To use AWS S3, version 3",
33+
"mhetreramesh/flysystem-backblaze": "To use B2",
3334
"srmklive/flysystem-dropbox-v2": "To use Dropbox",
3435
"league/flysystem-rackspace": "To use Rackspace",
3536
"league/flysystem-sftp": "To use sftp"

0 commit comments

Comments
 (0)