Skip to content

Commit

Permalink
Issue #3 support 'root' option.
Browse files Browse the repository at this point in the history
  • Loading branch information
judgej committed Nov 20, 2019
1 parent 9118176 commit 6616944
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -55,6 +55,7 @@ Add the following to your `config/filesystems.php`:
// Optional settings
'disableRecursiveDelete' => false,
'driverOptions' => [],
'root' => 'root/directory', // Without leading '/'
],
],
];
Expand Down
22 changes: 18 additions & 4 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
);
});
Expand Down

0 comments on commit 6616944

Please sign in to comment.