fix: register minio custom driver using flysystem-aws-s3-v3 (Laravel 5.0 hardcodes v2)
All checks were successful
Deploy Production (crewsportswear.com) / deploy (push) Successful in 2m5s
All checks were successful
Deploy Production (crewsportswear.com) / deploy (push) Successful in 2m5s
This commit is contained in:
@@ -4,6 +4,8 @@ use Illuminate\Support\ServiceProvider;
|
|||||||
use Storage;
|
use Storage;
|
||||||
use League\Flysystem\Filesystem;
|
use League\Flysystem\Filesystem;
|
||||||
use League\Flysystem\Sftp\SftpAdapter;
|
use League\Flysystem\Sftp\SftpAdapter;
|
||||||
|
use League\Flysystem\AwsS3v3\AwsS3Adapter as AwsS3v3Adapter;
|
||||||
|
use Aws\S3\S3Client;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider {
|
class AppServiceProvider extends ServiceProvider {
|
||||||
|
|
||||||
@@ -27,6 +29,21 @@ class AppServiceProvider extends ServiceProvider {
|
|||||||
Storage::extend('sftp', function ($app, $config) {
|
Storage::extend('sftp', function ($app, $config) {
|
||||||
return new Filesystem(new SftpAdapter($config));
|
return new Filesystem(new SftpAdapter($config));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Storage::extend('minio', function ($app, $config) {
|
||||||
|
$client = new S3Client([
|
||||||
|
'credentials' => [
|
||||||
|
'key' => $config['key'],
|
||||||
|
'secret' => $config['secret'],
|
||||||
|
],
|
||||||
|
'region' => $config['region'],
|
||||||
|
'version' => 'latest',
|
||||||
|
'endpoint' => $config['endpoint'],
|
||||||
|
'use_path_style_endpoint' => filter_var($config['use_path_style_endpoint'] ?? true, FILTER_VALIDATE_BOOLEAN),
|
||||||
|
]);
|
||||||
|
$adapter = new AwsS3v3Adapter($client, $config['bucket']);
|
||||||
|
return new Filesystem($adapter);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ return [
|
|||||||
],
|
],
|
||||||
|
|
||||||
'minio' => [
|
'minio' => [
|
||||||
'driver' => 's3',
|
'driver' => 'minio',
|
||||||
'key' => env('MINIO_KEY'),
|
'key' => env('MINIO_KEY'),
|
||||||
'secret' => env('MINIO_SECRET'),
|
'secret' => env('MINIO_SECRET'),
|
||||||
'region' => env('MINIO_REGION', 'us-east-1'),
|
'region' => env('MINIO_REGION', 'us-east-1'),
|
||||||
|
|||||||
Reference in New Issue
Block a user