Skip to content

Commit 7777e82

Browse files
committed
add adapter
1 parent 7d915e1 commit 7777e82

4 files changed

Lines changed: 75 additions & 18 deletions

File tree

README.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,51 @@
1-
# flysystem-backblaze
1+
# flysystem-b2
22

3-
[![Author](http://img.shields.io/badge/author-@mhetreramesh-blue.svg?style=flat-square)](https://twitter.com/mhetreramesh)
4-
[![Latest Version on Packagist](https://img.shields.io/packagist/v/mhetreramesh/flysystem-backblaze.svg?style=flat-square)](https://packagist.org/packages/mhetreramesh/flysystem-backblaze)
5-
[![Software License][ico-license]](LICENSE.md)
6-
[![Build Status](https://img.shields.io/travis/gliterd/flysystem-backblaze/master.svg?style=flat-square)](https://travis-ci.org/gliterd/flysystem-backblaze)
7-
[![Coverage Status][ico-scrutinizer]][link-scrutinizer]
8-
[![Quality Score][ico-code-quality]][link-code-quality]
9-
[![Total Downloads](https://img.shields.io/packagist/dt/mhetreramesh/flysystem-backblaze.svg?style=flat-square)](https://packagist.org/packages/mhetreramesh/flysystem-backblaze)
3+
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.
104

115
Visit (https://secure.backblaze.com/b2_buckets.htm) and get your account id, application key.
126

13-
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.
7+
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.
148

159
## Install
1610

1711
Via Composer
1812

1913
``` bash
20-
$ composer require mhetreramesh/flysystem-backblaze
14+
$ composer require runcloudio/flysystem-b2
2115
```
2216

23-
## Usage
17+
## Usage with Laravel
18+
19+
20+
In your app.php config file add to the list of service providers:
21+
```
22+
\RunCloudIO\FlysystemB2\BackblazeServiceProvider::class,
23+
```
24+
25+
Add the following to your filesystems.php config file in the ```disks``` section:
26+
```
27+
'b2' => [
28+
'driver' => 'b2',
29+
'accountId' => '',
30+
'applicationKey' => '',
31+
'bucketName' => '',
32+
],
33+
```
34+
35+
Just use it as you normally would use the Storage facade.
36+
```
37+
\Storage::disk('b2')->put('test.txt', 'test')
38+
```
39+
and
40+
```
41+
\Storage::disk('b2')->get('test.txt')
42+
```
43+
44+
45+
## Usage without Laravel
2446

2547
``` php
26-
use Mhetreramesh\Flysystem\BackblazeAdapter;
48+
use RunCloudIO\FlysystemB2\BackblazeAdapter;
2749
use League\Flysystem\Filesystem;
2850
use ChrisWhite\B2\Client;
2951

composer.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
{
2-
"name": "mhetreramesh/flysystem-backblaze",
2+
"name": "runcloudio/flysystem-b2",
33
"type": "library",
4-
"description": "Backblaze adapter for the flysystem filesystem abstraction library",
4+
"description": "Backblaze adapter for the flysystem filesystem abstraction library. A fork from https://github.com/mhetreramesh/flysystem-backblaze and maintained as separate package.",
55
"keywords": ["flysystem", "filesystem", "api", "backblaze", "client"],
6-
"homepage": "https://github.com/mhetreramesh/flysystem-backblaze",
6+
"homepage": "https://github.com/RunCloudIO/flysystem-b2",
77
"license": "MIT",
88
"authors": [
99
{
1010
"name": "Ramesh Mhetre",
1111
"email": "mhetreramesh@gmail.com",
1212
"homepage": "https://about.me/rameshmhetre",
1313
"role": "Developer"
14+
}, {
15+
"name": "Ahmad Fikrizaman",
16+
"email": "fikri@runcloud.io",
17+
"homepage": "https://runcloud.io",
18+
"role": "CTO"
1419
}
1520
],
1621
"require": {
@@ -26,12 +31,12 @@
2631
},
2732
"autoload": {
2833
"psr-4": {
29-
"Mhetreramesh\\Flysystem\\": "src"
34+
"RunCloudIO\\Flysystem\\": "src"
3035
}
3136
},
3237
"autoload-dev": {
3338
"psr-4": {
34-
"Mhetreramesh\\Flysystem\\Tests\\": "tests"
39+
"RunCloudIO\\Flysystem\\Tests\\": "tests"
3540
}
3641
},
3742
"scripts": {

src/BackblazeAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Mhetreramesh\Flysystem;
3+
namespace RunCloudIO\FlysystemB2;
44

55
use ChrisWhite\B2\Client;
66
use GuzzleHttp\Psr7\StreamWrapper;

src/BackblazeServiceProvider.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace RunCloudIO\FlysystemB2;
4+
5+
use ChrisWhite\B2\Client;
6+
use Illuminate\Support\Facades\Storage;
7+
use Illuminate\Support\ServiceProvider;
8+
use League\Flysystem\Filesystem;
9+
use RunCloudIO\FlysystemB2\BackblazeAdapter;
10+
11+
class BackblazeServiceProvider extends ServiceProvider
12+
{
13+
public function boot()
14+
{
15+
Storage::extend('b2', function ($app, $config) {
16+
if (!(
17+
isset($config['accountId']) ||
18+
isset($config['applicationKey']) ||
19+
isset($config['bucketName']))) {
20+
throw new \Exception('Please set all configuration keys. (accountId, applicationKey, bucketName)');
21+
}
22+
$client = new Client($config['accountId'], $config['applicationKey']);
23+
$adapter = new BackblazeAdapter($client, $config['bucketName']);
24+
return new Filesystem($adapter);
25+
});
26+
}
27+
public function register()
28+
{
29+
}
30+
}

0 commit comments

Comments
 (0)