MongoDB GridFS integration for Laravel's Storage API
Install the package using composer:
composer require matthewbdaly/laravel-gridfs-storage
On Laravel versions before 5.5 you also need to add the service provider to config/app.php
manually:
Matthewbdaly\LaravelGridFSStorage\GridFSStorageServiceProvider::class,
Then add this to the disks
section of config/filesystems.php
:
'gridfs' => [
'driver' => 'gridfs',
'name' => env('GRIDFS_STORAGE_NAME'),
],
Finally, add the field GRIDFS_STORAGE_NAME
to your .env
file with the appropriate credentials. Then you can set the gridfs
driver as either your default or cloud driver and use it to fetch and retrieve files as usual.
Unfortunately, league/flysystem-gridfs
hasn't been updated to reflect this. When it is, I'll be in a position to make this work with it.