File tree Expand file tree Collapse file tree 3 files changed +91
-0
lines changed
Expand file tree Collapse file tree 3 files changed +91
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace phpbu \App \Backup \Sync ;
4+
5+ use Aws \S3 \S3Client ;
6+
7+ /**
8+ * Backblaze Sync
9+ *
10+ * Docs example
11+ * https://help.backblaze.com/hc/en-us/articles/360046980814-Using-the-AWS-SDK-for-PHP-with-Backblaze-B2-Cloud-Storage
12+ *
13+ * @package phpbu
14+ * @subpackage Backup
15+ * @author Vladimir Konchakovsky <vk@etradeua.com>
16+ * @copyright Vladimir Konchakovsky <vk@etradeua.com>
17+ * @license https://opensource.org/licenses/MIT The MIT License (MIT)
18+ * @link http://phpbu.de/
19+ */
20+ class BackblazeS3 extends AmazonS3v3
21+ {
22+ /**
23+ * Create the Backblaze AWS client.
24+ *
25+ * @return \Aws\S3\S3Client
26+ */
27+ protected function createClient () : S3Client
28+ {
29+ $ endpoint = $ this ->createEndpoint ();
30+
31+ return new S3Client ([
32+ 'endpoint ' => $ endpoint ,
33+ 'region ' => $ this ->region ,
34+ 'version ' => 'latest ' ,
35+ 'credentials ' => [
36+ 'key ' => $ this ->key ,
37+ 'secret ' => $ this ->secret ,
38+ ]
39+ ]);
40+ }
41+
42+ /**
43+ * Generate Backblaze enpoint
44+ *
45+ * @return string
46+ */
47+ private function createEndpoint ()
48+ {
49+ return strtr ('https://s3.{region}.backblazeb2.com ' , '{region} ' , $ this ->region );
50+ }
51+ }
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ class Factory
6969 'amazons3 ' => '\\phpbu \\App \\Backup \\Sync \\AmazonS3v3 ' ,
7070 'amazons3-v3 ' => '\\phpbu \\App \\Backup \\Sync \\AmazonS3v3 ' ,
7171 'amazons3-v2 ' => '\\phpbu \\App \\Backup \\Sync \\AmazonS3v2 ' ,
72+ 'backblazes3 ' => '\\phpbu \\App \\Backup \\Sync \\BackblazeS3 ' ,
7273 'azureblob ' => '\\phpbu \\App \\Backup \\Sync \\AzureBlob ' ,
7374 'dropbox ' => '\\phpbu \\App \\Backup \\Sync \\Dropbox ' ,
7475 'ftp ' => '\\phpbu \\App \\Backup \\Sync \\Ftp ' ,
Original file line number Diff line number Diff line change 1+ <?php
2+ namespace phpbu \App \Backup \Sync ;
3+
4+ use phpbu \App \BaseMockery ;
5+ use PHPUnit \Framework \TestCase ;
6+
7+ /**
8+ * BackblazeS3Test
9+ *
10+ * @package phpbu
11+ * @subpackage tests
12+ * @author Vladimir Konchakovsaky <vk@etradeua.com>
13+ * @copyright Vladimir Konchakovsaky <vk@etradeua.com>
14+ * @license https://opensource.org/licenses/MIT The MIT License (MIT)
15+ * @link http://www.phpbu.de/
16+ */
17+ class BackblazeS3Test extends TestCase
18+ {
19+
20+ use BaseMockery;
21+
22+ /**
23+ * Tests AmazonS3::setUp
24+ */
25+ public function testSetUpOk ()
26+ {
27+ $ amazonS3 = new BackblazeS3 ();
28+ $ amazonS3 ->setup ([
29+ 'key ' => 'dummy-key ' ,
30+ 'secret ' => 'dummy-secret ' ,
31+ 'bucket ' => 'dummy-bucket ' ,
32+ 'region ' => 'dummy-region ' ,
33+ 'path ' => '/ '
34+ ]);
35+
36+ $ this ->assertTrue (true , 'no exception should occur ' );
37+ }
38+
39+ }
You can’t perform that action at this time.
0 commit comments