0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-22 15:57:29 +00:00

Extracted download response logic into controller method

Fixes incorrect 'Content-Disposition' header value.
Fixes 
This commit is contained in:
Dan Brown 2018-09-22 11:34:09 +01:00
parent c47b578599
commit 5c2e3f4e56
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
5 changed files with 27 additions and 44 deletions
app/Http/Controllers

View file

@ -299,10 +299,7 @@ class BookController extends Controller
{
$book = $this->entityRepo->getBySlug('book', $bookSlug);
$pdfContent = $this->exportService->bookToPdf($book);
return response()->make($pdfContent, 200, [
'Content-Type' => 'application/octet-stream',
'Content-Disposition' => 'attachment; filename="' . $bookSlug . '.pdf'
]);
return $this->downloadResponse($pdfContent, $bookSlug . '.pdf');
}
/**
@ -314,10 +311,7 @@ class BookController extends Controller
{
$book = $this->entityRepo->getBySlug('book', $bookSlug);
$htmlContent = $this->exportService->bookToContainedHtml($book);
return response()->make($htmlContent, 200, [
'Content-Type' => 'application/octet-stream',
'Content-Disposition' => 'attachment; filename="' . $bookSlug . '.html'
]);
return $this->downloadResponse($htmlContent, $bookSlug . '.html');
}
/**
@ -328,10 +322,7 @@ class BookController extends Controller
public function exportPlainText($bookSlug)
{
$book = $this->entityRepo->getBySlug('book', $bookSlug);
$htmlContent = $this->exportService->bookToPlainText($book);
return response()->make($htmlContent, 200, [
'Content-Type' => 'application/octet-stream',
'Content-Disposition' => 'attachment; filename="' . $bookSlug . '.txt'
]);
$textContent = $this->exportService->bookToPlainText($book);
return $this->downloadResponse($textContent, $bookSlug . '.txt');
}
}