File tree Expand file tree Collapse file tree 3 files changed +90
-0
lines changed
Expand file tree Collapse file tree 3 files changed +90
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ namespace phpbu \App \Backup \Sync ;
3+
4+ use Aws \S3 \S3Client ;
5+
6+ /**
7+ * Backblaze Sync
8+ *
9+ * Docs example https://help.backblaze.com/hc/en-us/articles/360046980814-Using-the-AWS-SDK-for-PHP-with-Backblaze-B2-Cloud-Storage
10+ *
11+ * @package phpbu
12+ * @subpackage Backup
13+ * @author Vladimir Konchakovsky <vk@etradeua.com>
14+ * @copyright Vladimir Konchakovsky <vk@etradeua.com>
15+ * @license https://opensource.org/licenses/MIT The MIT License (MIT)
16+ * @link http://phpbu.de/
17+ */
18+
19+ class BackblazeS3 extends AmazonS3v3 {
20+
21+ /**
22+ * Create the Backblaze AWS client.
23+ *
24+ * @return \Aws\S3\S3Client
25+ */
26+ protected function createClient () : S3Client
27+ {
28+ $ endpoint = $ this ->createEndpoint ();
29+
30+ return new S3Client ([
31+ 'endpoint ' => $ endpoint ,
32+ 'region ' => $ this ->region ,
33+ 'version ' => 'latest ' ,
34+ 'credentials ' => [
35+ 'key ' => $ this ->key ,
36+ 'secret ' => $ this ->secret ,
37+ ]
38+ ]);
39+ }
40+
41+ /**
42+ * Generate Backblaze enpoint
43+ *
44+ * @return string
45+ */
46+ protected function createEndpoint () {
47+ return sprintf ('https://s3.%s.backblazeb2.com ' , $ this ->region );
48+ }
49+
50+ }
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