X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/582158f70e6c63980cce17d408a0cc435a0d985f..refs/pull/1133/head:/app/Http/Controllers/ChapterController.php diff --git a/app/Http/Controllers/ChapterController.php b/app/Http/Controllers/ChapterController.php index b737afc6d..a50306552 100644 --- a/app/Http/Controllers/ChapterController.php +++ b/app/Http/Controllers/ChapterController.php @@ -1,9 +1,9 @@ entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug); $pdfContent = $this->exportService->chapterToPdf($chapter); - return response()->make($pdfContent, 200, [ - 'Content-Type' => 'application/octet-stream', - 'Content-Disposition' => 'attachment; filename="' . $chapterSlug . '.pdf' - ]); + return $this->downloadResponse($pdfContent, $chapterSlug . '.pdf'); } /** @@ -266,10 +263,7 @@ class ChapterController extends Controller { $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug); $containedHtml = $this->exportService->chapterToContainedHtml($chapter); - return response()->make($containedHtml, 200, [ - 'Content-Type' => 'application/octet-stream', - 'Content-Disposition' => 'attachment; filename="' . $chapterSlug . '.html' - ]); + return $this->downloadResponse($containedHtml, $chapterSlug . '.html'); } /** @@ -281,10 +275,7 @@ class ChapterController extends Controller public function exportPlainText($bookSlug, $chapterSlug) { $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug); - $containedHtml = $this->exportService->chapterToPlainText($chapter); - return response()->make($containedHtml, 200, [ - 'Content-Type' => 'application/octet-stream', - 'Content-Disposition' => 'attachment; filename="' . $chapterSlug . '.txt' - ]); + $chapterText = $this->exportService->chapterToPlainText($chapter); + return $this->downloadResponse($chapterText, $chapterSlug . '.txt'); } }