diff --git a/README.md b/README.md index cb396ad..dc54dae 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,10 @@ [![GitHub license](https://img.shields.io/github/license/academe/laravel-azure-file-storage-driver.svg)](https://github.com/academe/laravel-azure-file-storage-driver/blob/master/LICENCE) [![GitHub issues](https://img.shields.io/github/issues/academe/laravel-azure-file-storage-driver.svg)](https://github.com/academe/laravel-azure-file-storage-driver/issues) -# Microsoft Azure File Storage Filesystem Driver for Laravel 5 +# Microsoft Azure File Storage Filesystem Driver for Laravel 5 and 6 This package allows Microsoft Azure File Storage -to be used as a filesystem in laravel 5. +to be used as a filesystem in laravel 5 and 6. ## Installation @@ -55,6 +55,7 @@ Add the following to your `config/filesystems.php`: // Optional settings 'disableRecursiveDelete' => false, 'driverOptions' => [], + 'root' => 'root/directory', // Without leading '/' ], ], ]; diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index a4c45bc..e037e90 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -46,15 +46,29 @@ public function boot() [] // $optionsWithMiddlewares ); - $driverOptions = !empty($config['driverOptions']) - ? $config['driverOptions'] - : null; + $directoryPrefix = null; + + if (! empty($config['driverOptions'])) { + // If a string, then treat it like a prefix for legacy support. + + if (is_string($config['driverOptions'])) { + $directoryPrefix = $config['driverOptions']; + } + + if (is_array($config['driverOptions'])) { + $driverConfig = array_merge($driverConfig, $config['driverOptions']); + } + } + + if (! empty($config['root']) && is_string($config['root'])) { + $directoryPrefix = $config['root']; + } return new Filesystem( new AzureFileAdapter( $fileService, $driverConfig, - $driverOptions + $directoryPrefix ) ); });