Skip to content

Instantly share code, notes, and snippets.

@pengan1987
Created August 24, 2015 05:59
Show Gist options
  • Select an option

  • Save pengan1987/8cf5872a6042dc150016 to your computer and use it in GitHub Desktop.

Select an option

Save pengan1987/8cf5872a6042dc150016 to your computer and use it in GitHub Desktop.
Laravel 5 Windows Azure file system driver
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Azure\AzureAdapter;
use League\Flysystem\Filesystem;
use Storage;
use WindowsAzure\Common\ServicesBuilder;
/**
* Laravel 5 Windows Azure file system driver
* Reference: http://laravel.com/docs/5.0/filesystem
* Class AzureBlobServiceProvider
* @package App\Providers
*/
class AzureBlobServiceProvider extends ServiceProvider
{
public function boot()
{
Storage::extend('azureblob', function ($app, $config) {
$endpoint = sprintf('DefaultEndpointsProtocol=%s;AccountName=%s;AccountKey=%s',
$config['protocol'],
$config['account'],
$config['apikey']);
if ($config['emulator']) {
$endpoint = 'UseDevelopmentStorage=true';
}
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($endpoint);
return new Filesystem(new AzureAdapter($blobRestProxy, $config['container']));
});
}
public function register()
{
//
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment