diff --git a/README.md b/README.md index 7078d384..fa6456a0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/storage.svg) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord) -Utopia Storage library is simple and lite library for managing application storage. It supports multiple storage adapters. We already support AWS S3 storage, Digitalocean Spaces storage and Linode Object storage. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io). +Utopia Storage library is simple and lite library for managing application storage. It supports multiple storage adapters. We already support AWS S3 storage, Digitalocean Spaces storage, Backblaze B2 Cloud storage, Linode Object storage and Wasabi Cloud storage. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io). This library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project. diff --git a/composer.lock b/composer.lock index 0d990b13..bbdb9ec5 100644 --- a/composer.lock +++ b/composer.lock @@ -363,7 +363,11 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/semver/issues", +<<<<<<< HEAD "source": "https://github.com/composer/semver/tree/3.3.1" +======= + "source": "https://github.com/composer/semver/tree/3.2.9" +>>>>>>> 91f354487e987e5b0512c5a4fbe1bd3760d1e084 }, "funding": [ { @@ -379,7 +383,11 @@ "type": "tidelift" } ], +<<<<<<< HEAD "time": "2022-03-16T11:22:07+00:00" +======= + "time": "2022-02-04T13:58:43+00:00" +>>>>>>> 91f354487e987e5b0512c5a4fbe1bd3760d1e084 }, { "name": "composer/xdebug-handler", @@ -1110,12 +1118,12 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "77a32518733312af16a44300404e945338981de3" + "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3", - "reference": "77a32518733312af16a44300404e945338981de3", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706", + "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706", "shasum": "" }, "require": { @@ -1151,9 +1159,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.x" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0" }, - "time": "2022-03-15T21:29:03+00:00" + "time": "2022-01-04T19:58:01+00:00" }, { "name": "phpspec/prophecy", @@ -1229,12 +1237,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "9a61ec72f0d2b0b1d3f7431f90ab936b9c0e2062" + "reference": "9f4335cf4951de192c6aa763b19638bdc41a1290" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9a61ec72f0d2b0b1d3f7431f90ab936b9c0e2062", - "reference": "9a61ec72f0d2b0b1d3f7431f90ab936b9c0e2062", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9f4335cf4951de192c6aa763b19638bdc41a1290", + "reference": "9f4335cf4951de192c6aa763b19638bdc41a1290", "shasum": "" }, "require": { @@ -1298,7 +1306,7 @@ "type": "github" } ], - "time": "2022-03-08T06:18:06+00:00" + "time": "2022-03-03T16:15:10+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1547,12 +1555,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "5fc83848551ec5fc0086af8024efc9c42fcde559" + "reference": "5ff8c545a50226c569310a35f4fa89d79f1ddfdc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5fc83848551ec5fc0086af8024efc9c42fcde559", - "reference": "5fc83848551ec5fc0086af8024efc9c42fcde559", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5ff8c545a50226c569310a35f4fa89d79f1ddfdc", + "reference": "5ff8c545a50226c569310a35f4fa89d79f1ddfdc", "shasum": "" }, "require": { @@ -1642,7 +1650,7 @@ "type": "github" } ], - "time": "2022-03-15T10:09:15+00:00" + "time": "2022-02-23T17:10:58+00:00" }, { "name": "psr/container", @@ -2882,7 +2890,7 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.25.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -2944,7 +2952,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0" }, "funding": [ { @@ -2964,7 +2972,7 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.25.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", @@ -3025,7 +3033,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.24.0" }, "funding": [ { @@ -3045,7 +3053,7 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.25.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -3109,7 +3117,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.24.0" }, "funding": [ { @@ -3129,7 +3137,7 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.25.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", @@ -3192,7 +3200,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" }, "funding": [ { @@ -3212,7 +3220,7 @@ }, { "name": "symfony/polyfill-php73", - "version": "v1.25.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", @@ -3271,7 +3279,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0" }, "funding": [ { @@ -3291,7 +3299,7 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.25.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", @@ -3354,7 +3362,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0" }, "funding": [ { diff --git a/src/Storage/Device/BackBlaze.php b/src/Storage/Device/BackBlaze.php new file mode 100644 index 00000000..b0fcd597 --- /dev/null +++ b/src/Storage/Device/BackBlaze.php @@ -0,0 +1,53 @@ +headers['host'] = $bucket . '.' . 's3' . '.' . $region . '.backblazeb2.com'; + } + + /** + * @return string + */ + public function getName(): string + { + return 'BackBlaze B2 Storage'; + } + + /** + * @return string + */ + public function getDescription(): string + { + return 'BackBlaze B2 Storage'; + } +} diff --git a/src/Storage/Storage.php b/src/Storage/Storage.php index aea36b95..cc27a41e 100644 --- a/src/Storage/Storage.php +++ b/src/Storage/Storage.php @@ -13,7 +13,8 @@ class Storage const DEVICE_LOCAL = 'Local'; const DEVICE_S3 = 'S3'; const DEVICE_DO_SPACES = 'DOSpaces'; - const DEVICE_LINODE='Linode'; + const DEVICE_BACKBLAZE = 'BackBlaze'; + const DEVICE_LINODE= 'Linode'; /** * Devices. @@ -119,4 +120,4 @@ public static function human(int $bytes, $decimals = 2, $system = 'metric') return sprintf("%.{$decimals}f%s", $bytes / pow($mod, $factor), $units[$system][$factor]); } -} \ No newline at end of file +} diff --git a/tests/Storage/Device/BackBlazeTest.php b/tests/Storage/Device/BackBlazeTest.php new file mode 100644 index 00000000..b2db63eb --- /dev/null +++ b/tests/Storage/Device/BackBlazeTest.php @@ -0,0 +1,30 @@ +root = 'root'; + $key = $_SERVER['BACKBLAZE_ACCESS_KEY'] ?? ''; + $secret = $_SERVER['BACKBLAZE_SECRET'] ?? ''; + $bucket = "backblaze-demo"; + + $this->object = new BackBlaze($this->root, $key, $secret, $bucket, BackBlaze::US_WEST_004, BackBlaze::ACL_PRIVATE); + + } + + protected function getAdapterName(): string + { + return 'BackBlaze B2 Storage'; + } + + protected function getAdapterDescription(): string + { + return 'BackBlaze B2 Storage'; + } +}