1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Add inline download capability

This commit is contained in:
= 2021-09-20 21:16:28 +10:00
parent 3d28159702
commit 6c1b0c24d0
3 changed files with 22 additions and 5 deletions

View File

@ -589,14 +589,20 @@ class CreditController extends BaseController
public function downloadPdf($invitation_key)
{
$invitation = $this->credit_repository->getInvitationByKey($invitation_key);
// $contact = $invitation->contact;
$credit = $invitation->credit;
$file = $credit->service()->getCreditPdf($invitation);
$headers = ['Content-Type' => 'application/pdf'];
if(request()->input('inline') == 'true')
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
return response()->streamDownload(function () use($file) {
echo Storage::get($file);
}, basename($file), ['Content-Type' => 'application/pdf']);
}, basename($file), $headers);
}

View File

@ -804,9 +804,15 @@ class InvoiceController extends BaseController
$file = $invoice->service()->getInvoicePdf($contact);
$headers = ['Content-Type' => 'application/pdf'];
if(request()->input('inline') == 'true')
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
return response()->streamDownload(function () use($file) {
echo Storage::get($file);
}, basename($file), ['Content-Type' => 'application/pdf']);
}, basename($file), $headers);
}
/**

View File

@ -740,11 +740,16 @@ class QuoteController extends BaseController
$file = $quote->service()->getQuotePdf($contact);
$headers = ['Content-Type' => 'application/pdf'];
if(request()->input('inline') == 'true')
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
return response()->streamDownload(function () use($file) {
echo Storage::get($file);
}, basename($file), ['Content-Type' => 'application/pdf']);
}, basename($file), $headers);
// return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
}
/**