Download the PHP package steppinghat/backblaze-b2-bundle without Composer
On this page you can find all versions of the php package steppinghat/backblaze-b2-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download steppinghat/backblaze-b2-bundle
More information about steppinghat/backblaze-b2-bundle
Files in steppinghat/backblaze-b2-bundle
Package backblaze-b2-bundle
Short Description A Symfony compatible bundle for interfacing with the Backblaze B2 API
License MIT
Informations about the package backblaze-b2-bundle
Backblaze B2 API for Symfony
📼 Backblaze B2 API client services for Symfony projects
Installation
To install this bundle, run the following in your Symfony project directory:
Then register the bundle in config/bundles.php
And lastly, create a config file in config/packages
called backblaze_b2.yaml
Configuration
Backblaze API keys
Before setting off, you'll need to create a key by going to App Keys in your Backblaze Account.
Not all keys are created equal!
You can use an application key, however the capabilities are very limited in comparison to the master application key. Please bare this in mind when configuring the bundle.
Caching Tokens
In order to both reduce the number of API calls made, and speed up the overall turnaround time, we can optionally cache tokens to disk. This means that instead of requesting the authentication token needed to carry out requests every time, we use one from an earlier call that we've cached. These tokens last ~12 hours before they expire and a new one is needed.
While is can be preferable, some might not like the idea of keeping a token saved to disk for security reasons. If your
system is well secured and this isn't as much of a risk, turn this on by setting tokenCacheDirectory
to a valid
directory in that we have permissions to write to.
This cache is not cleared by running php bin/console cache:clear
Usage
For all basic usage of the API, simply use the BackblazeClient
class in your service.
- Create a bucket
- List all buckets
- Update a bucket
- Delete a bucket
- List all files
- Check if a file exists
- Get file info
- Delete a file
- Upload a file
- Download a file
Create a bucket
Requires the writeBuckets
capability
List all buckets
Requires the listBuckets
capability
Update a bucket
Requires the writeBuckets
capability
Delete a bucket
Requires the deleteBuckets
capability
List all files
Requires the listFiles
capability
Check if a file exists
Requires the listFiles
capability
Get file info
Requires the readFiles
capability
Delete a file
Requires the deleteFiles
capability
If a file has governance restrictions, access keys with the bypassGovernance
capability can force delete files.
Upload a file
Requires the writeFiles
capability
Files can be uploaded by either passing a string content
or files can be passed in as a resource
⚠ Resource content is loaded into memory before being sent. This is due to a limitation where the Symfony HttpClient library sends headers after the content, and the Backblaze API expects it before. As a result, we can't directly pass the resource directly to Backblaze. This is currently a //TODO to find a workaround for. If you intend to upload large files, this may be an issue.
Download a file
Requires the readFiles
capability
Downloaded content is simply returned into a variable
but can also be passed directly into a resource
Testing
In terms of tests, there are no tests. (Boooo).
This library is still a work in progress as I don't yet fully support the B2 API, nor have I ironed out 100% of the kinks (see uploading a resource for example).
Most of the functionality works (I use it in my own app), I guess you can call that some sort of guarantee?
But don't worry, once I've built out the library some more there will be tests - I promise!
License
Made with :heart: by Javan Eskander
Available for use under the MIT license.
All versions of backblaze-b2-bundle with dependencies
symfony/http-client Version ^5.4
symfony/config Version ^5.4
symfony/dependency-injection Version ^5.4
symfony/framework-bundle Version ^5.4
symfony/cache Version ^5.4