diff --git a/app/Http/Controllers/RecurringInvoiceController.php b/app/Http/Controllers/RecurringInvoiceController.php index 46c708d4b6f0..aef6b5e2e6ed 100644 --- a/app/Http/Controllers/RecurringInvoiceController.php +++ b/app/Http/Controllers/RecurringInvoiceController.php @@ -33,6 +33,7 @@ use App\Utils\Traits\SavesDocuments; use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Http\Response; +use Illuminate\Support\Facades\Storage; /** * Class RecurringInvoiceController. @@ -500,9 +501,12 @@ class RecurringInvoiceController extends BaseController $contact = $invitation->contact; $recurring_invoice = $invitation->recurring_invoice; - $file_path = $recurring_invoice->service()->getInvoicePdf($contact); + $file = $recurring_invoice->service()->getInvoicePdf($contact); + + return response()->streamDownload(function () use($file) { + echo Storage::get($file); + }, basename($file)); - return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); } /** diff --git a/app/Services/Recurring/GetInvoicePdf.php b/app/Services/Recurring/GetInvoicePdf.php index 2df250bd166f..ba50f3d9ce0b 100644 --- a/app/Services/Recurring/GetInvoicePdf.php +++ b/app/Services/Recurring/GetInvoicePdf.php @@ -41,14 +41,14 @@ class GetInvoicePdf extends AbstractService $file_path = $path.$this->entity->hashed_id.'.pdf'; - $disk = 'public'; + $disk = config('filesystems.default'); $file = Storage::disk($disk)->exists($file_path); if (! $file) { $file_path = CreateEntityPdf::dispatchNow($invitation); } - - return Storage::disk($disk)->path($file_path); + + return $file_path; } }