namespace BookStack\Exports\Controllers;
use BookStack\Entities\Queries\BookQueries;
+use BookStack\Exceptions\NotFoundException;
use BookStack\Exports\ExportFormatter;
+use BookStack\Exports\ZipExports\ZipExportBuilder;
use BookStack\Http\Controller;
use Throwable;
protected ExportFormatter $exportFormatter,
) {
$this->middleware('can:content-export');
+ $this->middleware('throttle:exports');
}
/**
return $this->download()->directly($textContent, $bookSlug . '.md');
}
+
+ /**
+ * Export a book to a contained ZIP export file.
+ * @throws NotFoundException
+ */
+ public function zip(string $bookSlug, ZipExportBuilder $builder)
+ {
+ $book = $this->queries->findVisibleBySlugOrFail($bookSlug);
+ $zip = $builder->buildForBook($book);
+
+ return $this->download()->streamedFileDirectly($zip, $bookSlug . '.zip', true);
+ }
}