From 538ea204378e2d35e166650a7f972148337bf2fc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 4 Jan 2022 12:52:17 +1100 Subject: [PATCH] Force public access to PDFs --- app/Jobs/Entity/CreateEntityPdf.php | 8 ++++---- app/Services/Invoice/GenerateDeliveryNote.php | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/Jobs/Entity/CreateEntityPdf.php b/app/Jobs/Entity/CreateEntityPdf.php index 41f788111f03..e0d32d9532c9 100644 --- a/app/Jobs/Entity/CreateEntityPdf.php +++ b/app/Jobs/Entity/CreateEntityPdf.php @@ -13,6 +13,7 @@ namespace App\Jobs\Entity; use App\Exceptions\FilePermissionsFailure; +use App\Libraries\MultiDB; use App\Models\Account; use App\Models\Credit; use App\Models\CreditInvitation; @@ -101,8 +102,7 @@ class CreateEntityPdf implements ShouldQueue public function handle() { - $start = microtime(true); - // nlog("Start ". $start); + MultiDB::setDb($this->company->db); /* Forget the singleton*/ App::forgetInstance('translator'); @@ -204,9 +204,9 @@ class CreateEntityPdf implements ShouldQueue try{ if(!Storage::disk($this->disk)->exists($path)) + Storage::disk($this->disk)->makeDirectory($path, 0775); - - Storage::disk($this->disk)->put($file_path, $pdf); + Storage::disk($this->disk)->put($file_path, $pdf, 'public'); } catch(\Exception $e) diff --git a/app/Services/Invoice/GenerateDeliveryNote.php b/app/Services/Invoice/GenerateDeliveryNote.php index 83c39c6c54d4..2abb02a8a80a 100644 --- a/app/Services/Invoice/GenerateDeliveryNote.php +++ b/app/Services/Invoice/GenerateDeliveryNote.php @@ -108,11 +108,9 @@ class GenerateDeliveryNote } if(!Storage::disk($this->disk)->exists($this->invoice->client->invoice_filepath($invitation))) + Storage::disk($this->disk)->makeDirectory($this->invoice->client->invoice_filepath($invitation), 0775); - - Storage::disk($this->disk)->put($file_path, $pdf); - - //return Storage::disk($this->disk)->path($file_path); + Storage::disk($this->disk)->put($file_path, $pdf, 'public'); return $file_path; }