Getting Amazon S3 storage working in Laravel has caused me a few headaches today, so I thought I’d blog about how I got it working for others (and future reference for myself!).

I started of with a tutorial which pointed me at the wrong version of the Amazon s3 adapter, but a quick check of the Laravel 5.1 Filesystem documentation revealed I’d got the wrong version, I needed league/flysystem-aws-s3-v3 ~1.0
I then setup the relevant details in the config/filesystems.php:
'cloud' => 's3',
...
's3' => [
'driver' => 's3',
'key' => 'KEY',
'secret' => 'SECRET',
'region' => 'REGION',
'bucket' => 'BUCKET',
],
Then I simply set this up as a test in routes.php:
use Illuminate\Contracts\Filesystem\Cloud;
Route::get('test', function(Cloud $filesystem){
$directories = $filesystem->directories('/');
dd($directories);
});
Hooray, all working. Leaving this here for anyone that might need it!
Photo by Galería de ► Bee, like bees! <3 
Leave a Reply