diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/EpubService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/EpubService.java index c9784c606..b5c0618a0 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/service/EpubService.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/EpubService.java @@ -1,25 +1,24 @@ package com.adityachandel.booklore.service; +import com.adityachandel.booklore.exception.ApiError; +import com.adityachandel.booklore.model.entity.BookEntity; +import com.adityachandel.booklore.repository.BookRepository; +import lombok.AllArgsConstructor; import org.springframework.core.io.ByteArrayResource; import org.springframework.stereotype.Service; -import java.io.File; import java.io.FileInputStream; import java.io.IOException; +@AllArgsConstructor @Service public class EpubService { - // Method to retrieve the EPUB file as a ByteArrayResource - public ByteArrayResource getEpubFile(Long bookId) throws IOException { - String bookPath = "/Users/aditya.chandel/Downloads/Harry1.epub"; // Example path - File file = new File(bookPath); - if (!file.exists()) { - throw new IOException("EPUB file not found for book id: " + bookId); - } + private final BookRepository bookRepository; - // Convert the EPUB file to a byte array - try (FileInputStream inputStream = new FileInputStream(file)) { + public ByteArrayResource getEpubFile(Long bookId) throws IOException { + BookEntity bookEntity = bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId)); + try (FileInputStream inputStream = new FileInputStream(bookEntity.getPath())) { byte[] fileContent = inputStream.readAllBytes(); return new ByteArrayResource(fileContent); } diff --git a/booklore-ui/src/app/epub-viewer/component/epub-viewer.component.ts b/booklore-ui/src/app/epub-viewer/component/epub-viewer.component.ts index c73a48d99..e04b92699 100644 --- a/booklore-ui/src/app/epub-viewer/component/epub-viewer.component.ts +++ b/booklore-ui/src/app/epub-viewer/component/epub-viewer.component.ts @@ -31,7 +31,7 @@ export class EpubViewerComponent implements OnInit, OnDestroy { private book: any; private rendition: any; private keyListener: (e: KeyboardEvent) => void = () => {}; - fontSize: number = 100; + fontSize: number = 120; fontTypes: any[] = [ {label: 'Serif', value: 'serif'},