Skip to content

Instantly share code, notes, and snippets.

@alixcan
Created May 30, 2020 22:24
Show Gist options
  • Save alixcan/95c5d7520ecb25eba942459ef2dcf47e to your computer and use it in GitHub Desktop.
Save alixcan/95c5d7520ecb25eba942459ef2dcf47e to your computer and use it in GitHub Desktop.
Laravel BackBlaze Adapter
BB_KEY=
BB_SECRET=""
BB_REGION=
BB_BUCKET=
BB_ENDPOINT=
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
use Storage;
class BackBlazeProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
Storage::extend('back-blaze', function ($app, $config) {
$client = new S3Client([
'credentials' => [
'key' => $config["key"],
'secret' => $config["secret"],
],
'region' => $config["region"],
'version' => "latest",
'bucket_endpoint' => false,
'use_path_style_endpoint' => false,
'endpoint' => $config["endpoint"],
]);
return new Filesystem(new AwsS3Adapter($client, $config["bucket"]));
});
}
}
<?php
return [
'back-blaze' => [
'driver' => 'back-blaze',
'key' => env('BB_KEY'),
'secret' => env('BB_SECRET'),
'region' => env('BB_REGION'), // can be anything
'bucket' => env('BB_BUCKET'),// your space name
'endpoint' => env('BB_ENDPOINT') // spaces endpoint (currently : `https://nyc3.digitaloceanspaces.com`)
]
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment