zaxbux/backblaze-b2-php
最新稳定版本:v2.0.2
Composer 安装命令:
composer require zaxbux/backblaze-b2-php
包简介
A SDK for working with B2 cloud storage.
README 文档
README
backblaze-b2-php is a client library for working with the B2 cloud storage service from Backblaze.
Documentation
Full documentation of the Backblaze B2 API can be found here.
Complete documentation for this library does not exist yet, however most methods are already documented in the source code.
Installation
Installation is via Composer:
$ composer require zaxbux/backblaze-b2-php
Getting Started
<?php use Zaxbux\BackblazeB2\Client; $accountId = '...'; $applicationKey = '...'; $client = new Client([$accountId, $applicationKey]); // Retrieve an array of Bucket objects on your account. $buckets = $client->listBuckets();
Authorization Cache
If you want to cache the authorization token to reduce the number of API calls, create a class that implements Zaxbux\BackblazeB2\Interfaces\AuthorizationCacheInterface.
<?php use Zaxbux\BackblazeB2\Client; $authCache = new AuthorizationCacheExample; $client = new Client(new Config($accountId, $applicationKey, [ 'authorizationCache' => $authCache, ]));
Sample Authorization Cache
<?php use Zaxbux\BackblazeB2\Interfaces\AuthorizationCacheInterface; class AuthorizationCacheExample implements AuthorizationCacheInterface { public function cache($key, $value) { $myCache->remember($key, $value, AuthorizationCacheInterface::EXPIRES) } public function get($key) { $myCache->get($key); } }
The AuthorizationCacheInterface::EXPIRES constant is how long the authorization token is valid for, in seconds. Currently, this is equivalent to 24 hours. Requests made after the token expires will result in an ExpiredAuthTokenException exception being thrown. You will need to get a new authorization token with authorizeAccount().
Tests
Tests are run with PHPUnit. After installing PHPUnit via Composer:
$ vendor/bin/phpunit
Contributing
Feel free to contribute in any way by reporting an issue, making a suggestion, or submitting a pull request.
Licence
统计信息
- 总下载量: 2.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-08