diff --git a/app/Http/Controllers/ProtectedDownloadController.php b/app/Http/Controllers/ProtectedDownloadController.php index c333539b99ab..b8f598a11021 100644 --- a/app/Http/Controllers/ProtectedDownloadController.php +++ b/app/Http/Controllers/ProtectedDownloadController.php @@ -11,6 +11,7 @@ namespace App\Http\Controllers; +use App\Utils\Ninja; use Illuminate\Http\Request; use App\Jobs\Util\UnlinkFile; use App\Exceptions\SystemError; diff --git a/app/Jobs/Company/CompanyExport.php b/app/Jobs/Company/CompanyExport.php index 2b693dbabb12..2b89028e8a1c 100644 --- a/app/Jobs/Company/CompanyExport.php +++ b/app/Jobs/Company/CompanyExport.php @@ -441,15 +441,15 @@ class CompanyExport implements ShouldQueue $path = 'backups'; - Storage::makeDirectory(public_path('storage/backups/')); + Storage::makeDirectory(storage_path('backups/')); try { - mkdir(public_path('storage/backups/')); + mkdir(storage_path('backups/')); } catch(\Exception $e) { nlog("could not create directory"); } - $zip_path = public_path('storage/backups/'.$file_name); + $zip_path = storage_path('backups/'.$file_name); $zip = new \ZipArchive(); if ($zip->open($zip_path, \ZipArchive::CREATE)!==true) { @@ -459,14 +459,16 @@ class CompanyExport implements ShouldQueue $zip->addFromString("backup.json", json_encode($this->export_data)); $zip->close(); - if (Ninja::isHosted()) { - Storage::disk(config('filesystems.default'))->put('backups/'.$file_name, file_get_contents($zip_path)); - } + Storage::disk(config('filesystems.default'))->put('backups/'.$file_name, file_get_contents($zip_path)); + unlink($zip_path); - $storage_file_path = Storage::disk(config('filesystems.default'))->url('backups/'.$file_name); - $storage_path = Storage::disk(config('filesystems.default'))->path('backups/'.$file_name); + if(Ninja::isSelfHost()) + $storage_path = 'backups/'.$file_name; + else + $storage_path = Storage::disk(config('filesystems.default'))->path('backups/'.$file_name); $url = Cache::get($this->hash); + Cache::put($this->hash, $storage_path, now()->addHour()); App::forgetInstance('translator');