1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-06 12:02:45 +03:00

Implement functionality to export a book, along with its pages and chapters, as a ZIP file.

This commit is contained in:
nchoudhary@logicmines.in
2025-04-25 12:45:09 +05:30
parent fa566f156a
commit c61ce8dee4
3 changed files with 41 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ namespace BookStack\Exports\Controllers;
use BookStack\Entities\Queries\BookQueries;
use BookStack\Exports\ExportFormatter;
use BookStack\Exports\ZipExports\ZipExportBuilder;
use BookStack\Http\ApiController;
use Throwable;
@@ -63,4 +64,19 @@ class BookExportApiController extends ApiController
return $this->download()->directly($markdown, $book->slug . '.md');
}
}
/**
* Export a book to a contained ZIP export file.
* @throws NotFoundException
*/
public function exportZip(int $id, ZipExportBuilder $builder)
{
$book = $this->queries->findVisibleByIdOrFail($id);
$bookName= $book->getShortName();
$zip = $builder->buildForBook($book);
return $this->download()->streamedFileDirectly($zip, $bookName . '.zip', filesize($zip), true);
}
}