ZipResourceProvider

The ZipResourceProvider is used for fetching resources from a ZIP archive. It reads ZIP archive data from a RandomAccessDataSource.

The ReadingSystemEngine uses the ZipResourceProvider class internally when you load an EPUB using a RandomAccessDataSource. You can also construct a new instance by calling one of:

When you create a ZipResourceProvider using ReadingSystemEngine.createZipResourceProvider, the implementation will pre-calculate all byte ranges that will be used when fetching data chunks from the ZIP archive. This is a deterministic operation based on the ZipResourceProviderOptions and the ZIP archive. ZipResourceProvider.zipArchiveInformation provides a complete list of the pre-calculated byte ranges.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val baseUrl: String?

The base URL for this ResourceProvider, if it has one.

Link copied to clipboard
abstract val chunkCacheSize: Int

Cache size in bytes

Link copied to clipboard
abstract override val resourceManifest: List<ResourceMetadata>

Get a list about all files in this ZIP archive.

Link copied to clipboard
Link copied to clipboard

Information about the resource and its structure

Functions

Link copied to clipboard
abstract fun acceptsUrl(url: String): Boolean

Returns true if this ResourceProvider can handle the given relative or absolute URL.

Link copied to clipboard
abstract fun fetch(url: String, options: ResourceRequestOptions = ResourceRequestOptions()): ResourceResponse

Synchronously fetches a resource from this ResourceProvider using the provided url. The method returns when a successful response is available, or throws an exception on failure.

Link copied to clipboard
abstract fun fetchMetadata(url: String, options: ResourceRequestOptions = ResourceRequestOptions()): ResourceMetadata

Synchronously fetches metadata about a resource from this ResourceProvider. The method returns when resource metadata is available, or throws an Exception on failure.