forked from gliterd/flysystem-backblaze
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d915e1
commit 7777e82
Showing
4 changed files
with
75 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,51 @@ | ||
# flysystem-backblaze | ||
# flysystem-b2 | ||
|
||
[![Author](http://img.shields.io/badge/[email protected]?style=flat-square)](https://twitter.com/mhetreramesh) | ||
[![Latest Version on Packagist](https://img.shields.io/packagist/v/mhetreramesh/flysystem-backblaze.svg?style=flat-square)](https://packagist.org/packages/mhetreramesh/flysystem-backblaze) | ||
[![Software License][ico-license]](LICENSE.md) | ||
[![Build Status](https://img.shields.io/travis/gliterd/flysystem-backblaze/master.svg?style=flat-square)](https://travis-ci.org/gliterd/flysystem-backblaze) | ||
[![Coverage Status][ico-scrutinizer]][link-scrutinizer] | ||
[![Quality Score][ico-code-quality]][link-code-quality] | ||
[![Total Downloads](https://img.shields.io/packagist/dt/mhetreramesh/flysystem-backblaze.svg?style=flat-square)](https://packagist.org/packages/mhetreramesh/flysystem-backblaze) | ||
This is a fork based on https://github.com/mhetreramesh/flysystem-backblaze. It includes download file stream. Since B2 SDK from original package no longer maintained (Last PR merge is November 2016), I'm including the B2 SDK that I've forked and modified. This package also include ServiceProvider for Laravel. | ||
|
||
Visit (https://secure.backblaze.com/b2_buckets.htm) and get your account id, application key. | ||
|
||
The Backblaze adapter gives the possibility to use the Flysystem filesystem abstraction library with backblaze. It uses the [Backblaze B2 SDK](https://github.com/cwhite92/b2-sdk-php) to communicate with the API. | ||
The Backblaze adapter gives the possibility to use the Flysystem filesystem abstraction library with backblaze. It uses the [Backblaze B2 SDK](https://github.com/RunCloudIO/b2-sdk-php) to communicate with the API. | ||
|
||
## Install | ||
|
||
Via Composer | ||
|
||
``` bash | ||
$ composer require mhetreramesh/flysystem-backblaze | ||
$ composer require runcloudio/flysystem-b2 | ||
``` | ||
|
||
## Usage | ||
## Usage with Laravel | ||
|
||
|
||
In your app.php config file add to the list of service providers: | ||
``` | ||
\RunCloudIO\FlysystemB2\BackblazeServiceProvider::class, | ||
``` | ||
|
||
Add the following to your filesystems.php config file in the ```disks``` section: | ||
``` | ||
'b2' => [ | ||
'driver' => 'b2', | ||
'accountId' => '', | ||
'applicationKey' => '', | ||
'bucketName' => '', | ||
], | ||
``` | ||
|
||
Just use it as you normally would use the Storage facade. | ||
``` | ||
\Storage::disk('b2')->put('test.txt', 'test') | ||
``` | ||
and | ||
``` | ||
\Storage::disk('b2')->get('test.txt') | ||
``` | ||
|
||
|
||
## Usage without Laravel | ||
|
||
``` php | ||
use Mhetreramesh\Flysystem\BackblazeAdapter; | ||
use RunCloudIO\FlysystemB2\BackblazeAdapter; | ||
use League\Flysystem\Filesystem; | ||
use ChrisWhite\B2\Client; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
{ | ||
"name": "mhetreramesh/flysystem-backblaze", | ||
"name": "runcloudio/flysystem-b2", | ||
"type": "library", | ||
"description": "Backblaze adapter for the flysystem filesystem abstraction library", | ||
"description": "Backblaze adapter for the flysystem filesystem abstraction library. A fork from https://github.com/mhetreramesh/flysystem-backblaze and maintained as separate package.", | ||
"keywords": ["flysystem", "filesystem", "api", "backblaze", "client"], | ||
"homepage": "https://github.com/mhetreramesh/flysystem-backblaze", | ||
"homepage": "https://github.com/RunCloudIO/flysystem-b2", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Ramesh Mhetre", | ||
"email": "[email protected]", | ||
"homepage": "https://about.me/rameshmhetre", | ||
"role": "Developer" | ||
}, { | ||
"name": "Ahmad Fikrizaman", | ||
"email": "[email protected]", | ||
"homepage": "https://runcloud.io", | ||
"role": "CTO" | ||
} | ||
], | ||
"require": { | ||
|
@@ -26,12 +31,12 @@ | |
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Mhetreramesh\\Flysystem\\": "src" | ||
"RunCloudIO\\Flysystem\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Mhetreramesh\\Flysystem\\Tests\\": "tests" | ||
"RunCloudIO\\Flysystem\\Tests\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace RunCloudIO\FlysystemB2; | ||
|
||
use ChrisWhite\B2\Client; | ||
use Illuminate\Support\Facades\Storage; | ||
use Illuminate\Support\ServiceProvider; | ||
use League\Flysystem\Filesystem; | ||
use RunCloudIO\FlysystemB2\BackblazeAdapter; | ||
|
||
class BackblazeServiceProvider extends ServiceProvider | ||
{ | ||
public function boot() | ||
{ | ||
Storage::extend('b2', function ($app, $config) { | ||
if (!( | ||
isset($config['accountId']) || | ||
isset($config['applicationKey']) || | ||
isset($config['bucketName']))) { | ||
throw new \Exception('Please set all configuration keys. (accountId, applicationKey, bucketName)'); | ||
} | ||
$client = new Client($config['accountId'], $config['applicationKey']); | ||
$adapter = new BackblazeAdapter($client, $config['bucketName']); | ||
return new Filesystem($adapter); | ||
}); | ||
} | ||
public function register() | ||
{ | ||
} | ||
} |