From 0f1dbefde89dee57f786352b46805508d6d07b18 Mon Sep 17 00:00:00 2001 From: Melek REBAI Date: Sat, 5 Nov 2016 17:10:36 +0100 Subject: [PATCH 1/2] Use 'url_root' config value to generate disk url --- src/Illuminate/Filesystem/FilesystemAdapter.php | 6 ++++++ src/Illuminate/Filesystem/FilesystemManager.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php index 361d87400a90..d9ed5c08df96 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -287,6 +287,12 @@ public function url($path) return $adapter->getClient()->getObjectUrl($adapter->getBucket(), $path); } elseif ($adapter instanceof LocalAdapter) { + $flysystemConfig = $this->driver->getConfig(); + + if ($flysystemConfig->has('url_root')) { + return $flysystemConfig->get('url_root') .'/'. $path; + } + $path = '/storage/'.$path; return Str::contains($path, '/storage/public') ? Str::replaceFirst('/public', '', $path) : $path; diff --git a/src/Illuminate/Filesystem/FilesystemManager.php b/src/Illuminate/Filesystem/FilesystemManager.php index 542e6604cb6e..380ac097d632 100644 --- a/src/Illuminate/Filesystem/FilesystemManager.php +++ b/src/Illuminate/Filesystem/FilesystemManager.php @@ -255,7 +255,7 @@ protected function getRackspaceContainer(Rackspace $client, array $config) */ protected function createFlysystem(AdapterInterface $adapter, array $config) { - $config = Arr::only($config, ['visibility', 'disable_asserts']); + $config = Arr::only($config, ['visibility', 'disable_asserts', 'url_root']); return new Flysystem($adapter, count($config) > 0 ? $config : null); } From 0e1692e9a11968a2663c6ef0cfe114e9be73d68f Mon Sep 17 00:00:00 2001 From: Melek REBAI Date: Sat, 5 Nov 2016 17:26:31 +0100 Subject: [PATCH 2/2] StyleCi formatting --- src/Illuminate/Filesystem/FilesystemAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php index d9ed5c08df96..5ba22a4d1934 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -290,7 +290,7 @@ public function url($path) $flysystemConfig = $this->driver->getConfig(); if ($flysystemConfig->has('url_root')) { - return $flysystemConfig->get('url_root') .'/'. $path; + return $flysystemConfig->get('url_root').'/'.$path; } $path = '/storage/'.$path;