Skip to content

Commit

Permalink
add adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
coolcodemy committed Aug 24, 2017
1 parent 7d915e1 commit 7777e82
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 18 deletions.
46 changes: 34 additions & 12 deletions README.md
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;

Expand Down
15 changes: 10 additions & 5 deletions composer.json
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": {
Expand All @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/BackblazeAdapter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Mhetreramesh\Flysystem;
namespace RunCloudIO\FlysystemB2;

use ChrisWhite\B2\Client;
use GuzzleHttp\Psr7\StreamWrapper;
Expand Down
30 changes: 30 additions & 0 deletions src/BackblazeServiceProvider.php
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()
{
}
}

0 comments on commit 7777e82

Please sign in to comment.