- $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');
+ }
+
+ /**
+ * Common actions to run on book update.
+ * Handles updating the cover image.
+ * @param Book $book
+ * @param Request $request
+ * @throws \BookStack\Exceptions\ImageUploadException
+ */
+ protected function bookUpdateActions(Book $book, Request $request)
+ {
+ // Update the cover image if in request
+ if ($request->has('image')) {
+ $this->imageRepo->destroyImage($book->cover);
+ $newImage = $request->file('image');
+ $image = $this->imageRepo->saveNew($newImage, 'cover_book', $book->id, 512, 512, true);
+ $book->image_id = $image->id;
+ $book->save();
+ }
+
+ if ($request->has('image_reset')) {
+ $this->imageRepo->destroyImage($book->cover);
+ $book->image_id = 0;
+ $book->save();
+ }