Last active
January 4, 2017 19:36
-
-
Save gbaudoin/4f39ce18c6ee10f20bf36fa18a979216 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
namespace App\Providers; | |
use Storage; | |
use League\Flysystem\Filesystem; | |
use OpenStack\OpenStack; | |
use Illuminate\Support\ServiceProvider; | |
use Nimbusoft\Flysystem\OpenStack\SwiftAdapter; | |
use OpenStack\Identity\v2\Service; | |
use GuzzleHttp\Client; | |
use GuzzleHttp\HandlerStack; | |
use OpenStack\Common\Transport\Utils; | |
class SwiftServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap the application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
Storage::extend('swift', function ($app, $config) { | |
$options = [ | |
'authUrl' => $config['endpoint'], | |
'region' => $config['region'], | |
'username' => $config['username'], | |
'password' => $config['password'], | |
'tenantName' => $config['tenantName'], | |
'publicUrl' => $config['publicUrl'], | |
]; | |
$clientOptions = [ | |
'base_uri' => Utils::normalizeUrl($options['authUrl']), | |
'handler' => HandlerStack::create(), | |
]; | |
$options['identityService'] = Service::factory(new Client($clientOptions)); | |
$openstack = new OpenStack($options); | |
$container = $openstack->objectStoreV1()->getContainer($config['container']); | |
$adapter = new SwiftAdapter($container); | |
return new Filesystem($adapter); | |
}); | |
} | |
/** | |
* Register the application services. | |
* | |
* @return void | |
*/ | |
public function register() | |
{ | |
// | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
line 27: