- Install
composer require league/flysystem-aws-s3-v3
to your laravel app - Create new file in ('app/Providers')
DOSpacesStorageServiceProvider.php
- Add
App\Providers\DOSpacesStorageServiceProvider::class
toconfig/app.php
- Add this array block to
filesystems.php
config indisks
section (config/filesystems.php
) :'do-spaces' => [ 'driver' => 'do-spaces', 'key' => env('SPACES_KEY'), 'secret' => env('SPACES_SECRET'), 'region' => env('SPACES_REGION'), // can be anything 'bucket' => env('SPACES_BUCKET'),// your space name 'endpoint' => env('SPACES_ENDPOINT') // spaces endpoint (currently : `https://nyc3.digitaloceanspaces.com`) ]
- Done!
Last active
January 1, 2021 01:20
-
-
Save masitings/64907fbd4b719a4802873e3f54fbf3dd to your computer and use it in GitHub Desktop.
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 DOSpacesStorageServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap the application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
Storage::extend('do-spaces', 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"])); | |
}); | |
} | |
/** | |
* 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