refactor(download): simplify file download to use browser native handling (#2639)

This commit is contained in:
ACX
2026-02-06 13:05:09 -07:00
committed by GitHub
parent 5183b0ddfc
commit b98663acf0
8 changed files with 21 additions and 407 deletions
@@ -355,10 +355,10 @@ export class BookService {
downloadAllFiles(book: Book): void {
const downloadUrl = `${this.url}/${book.id}/download-all`;
const fileName = book.metadata?.title
const filename = book.metadata?.title
? `${book.metadata.title.replace(/[^a-zA-Z0-9\-_]/g, '_')}.zip`
: `book-${book.id}.zip`;
this.fileDownloadService.downloadFile(downloadUrl, fileName);
this.fileDownloadService.downloadFile(downloadUrl, filename);
}
deleteAdditionalFile(bookId: number, fileId: number): Observable<void> {
@@ -527,8 +527,8 @@ export class BookService {
...(book.alternativeFormats || []),
...(book.supplementaryFiles || [])
].find((f: AdditionalFile) => f.id === fileId);
const downloadUrl = `${this.url}/${book!.id}/files/${fileId}/download`;
this.fileDownloadService.downloadFile(downloadUrl, additionalFile!.fileName!);
const downloadUrl = `${this.url}/${book.id}/files/${fileId}/download`;
this.fileDownloadService.downloadFile(downloadUrl, additionalFile?.fileName ?? 'file');
}
/*------------------ Progress & Status Tracking ------------------*/