Created
August 13, 2019 05:26
-
-
Save lesstif/376643b544f02e164a71e7a366ee22c1 to your computer and use it in GitHub Desktop.
MinIO Storage ServiceProvider for PHP Laravel
This file contains 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 Illuminate\Support\ServiceProvider; | |
use Aws\S3\S3Client; | |
use League\Flysystem\AwsS3v3\AwsS3Adapter; | |
use League\Flysystem\Filesystem; | |
use Storage; | |
class MinIOStorageServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap the application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
Storage::extend('minio', 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' => true, | |
'endpoint' => $config["endpoint"], | |
]); | |
$options = [ | |
'override_visibility_on_copy' => true | |
]; | |
return new Filesystem(new AwsS3Adapter($client, $config["bucket"], '', $options)); | |
}); | |
} | |
/** | |
* 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