Skip to content

Commit 6616944

Browse files
committed
Issue #3 support 'root' option.
1 parent 9118176 commit 6616944

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
[![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)
66
[![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)
77

8-
# Microsoft Azure File Storage Filesystem Driver for Laravel 5
8+
# Microsoft Azure File Storage Filesystem Driver for Laravel 5 and 6
99

1010
This package allows Microsoft Azure File Storage
11-
to be used as a filesystem in laravel 5.
11+
to be used as a filesystem in laravel 5 and 6.
1212

1313
## Installation
1414

@@ -55,6 +55,7 @@ Add the following to your `config/filesystems.php`:
5555
// Optional settings
5656
'disableRecursiveDelete' => false,
5757
'driverOptions' => [],
58+
'root' => 'root/directory', // Without leading '/'
5859
],
5960
],
6061
];

src/ServiceProvider.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,29 @@ public function boot()
4646
[] // $optionsWithMiddlewares
4747
);
4848

49-
$driverOptions = !empty($config['driverOptions'])
50-
? $config['driverOptions']
51-
: null;
49+
$directoryPrefix = null;
50+
51+
if (! empty($config['driverOptions'])) {
52+
// If a string, then treat it like a prefix for legacy support.
53+
54+
if (is_string($config['driverOptions'])) {
55+
$directoryPrefix = $config['driverOptions'];
56+
}
57+
58+
if (is_array($config['driverOptions'])) {
59+
$driverConfig = array_merge($driverConfig, $config['driverOptions']);
60+
}
61+
}
62+
63+
if (! empty($config['root']) && is_string($config['root'])) {
64+
$directoryPrefix = $config['root'];
65+
}
5266

5367
return new Filesystem(
5468
new AzureFileAdapter(
5569
$fileService,
5670
$driverConfig,
57-
$driverOptions
71+
$directoryPrefix
5872
)
5973
);
6074
});

0 commit comments

Comments
 (0)