From 81d9e4994cec2cf3570efe0bf69f389158a31e35 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 28 Apr 2017 14:20:17 +0300 Subject: [PATCH] Support setting file import path --- app/Services/ImportService.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index 478c0f4033c5..3d7c3d325c43 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -148,7 +148,7 @@ class ImportService public function importJSON($file, $includeData, $includeSettings) { $this->initMaps(); - $fileName = storage_path() . '/import/' . $file; + $fileName = $this->getFullPath($file); $this->checkForFile($fileName); $file = file_get_contents($fileName); $json = json_decode($file, true); @@ -287,7 +287,7 @@ class ImportService // Convert the data $row_list = []; - $fileName = storage_path() . '/import/' . $file; + $fileName = $this->getFullPath($file); $this->checkForFile($fileName); Excel::load($fileName, function ($reader) use ($source, $entityType, &$row_list, &$results) { @@ -590,7 +590,7 @@ class ImportService { require_once app_path().'/Includes/parsecsv.lib.php'; - $fileName = storage_path() . '/import/' . $fileName; + $fileName = $this->getFullPath($fileName); $this->checkForFile($fileName); $csv = new parseCSV(); @@ -726,7 +726,7 @@ class ImportService } } - @unlink(storage_path() . '/import/' . $fileName); + @unlink($this->getFullPath($fileName)); return $results; } @@ -956,4 +956,9 @@ class ImportService return true; } + + public function getFullPath($fileName) + { + return (env('FILE_IMPORT_PATH') ?: storage_path() . '/import') . '/' . $fileName; + } }