1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Extracted download response logic to its own class

Cleans up base controller and groups up download & streaming logic for
potential future easier addition of range request support.
This commit is contained in:
Dan Brown
2022-06-08 23:50:42 +01:00
parent e72ade727d
commit abc283fc64
11 changed files with 108 additions and 106 deletions

View File

@ -29,7 +29,7 @@ class ChapterExportApiController extends ApiController
$chapter = Chapter::visible()->findOrFail($id);
$pdfContent = $this->exportFormatter->chapterToPdf($chapter);
return $this->downloadResponse($pdfContent, $chapter->slug . '.pdf');
return $this->download()->directly($pdfContent, $chapter->slug . '.pdf');
}
/**
@ -42,7 +42,7 @@ class ChapterExportApiController extends ApiController
$chapter = Chapter::visible()->findOrFail($id);
$htmlContent = $this->exportFormatter->chapterToContainedHtml($chapter);
return $this->downloadResponse($htmlContent, $chapter->slug . '.html');
return $this->download()->directly($htmlContent, $chapter->slug . '.html');
}
/**
@ -53,7 +53,7 @@ class ChapterExportApiController extends ApiController
$chapter = Chapter::visible()->findOrFail($id);
$textContent = $this->exportFormatter->chapterToPlainText($chapter);
return $this->downloadResponse($textContent, $chapter->slug . '.txt');
return $this->download()->directly($textContent, $chapter->slug . '.txt');
}
/**
@ -64,6 +64,6 @@ class ChapterExportApiController extends ApiController
$chapter = Chapter::visible()->findOrFail($id);
$markdown = $this->exportFormatter->chapterToMarkdown($chapter);
return $this->downloadResponse($markdown, $chapter->slug . '.md');
return $this->download()->directly($markdown, $chapter->slug . '.md');
}
}