Skip to content

//readium-shared/org.readium.r2.shared.util.mediatype

Package-level declarations

Types

Name Summary
MediaType [androidJvm]
class MediaType(string: String, val name: String? = null, val fileExtension: String? = null)
Represents a document format, identified by a unique RFC 6838 media type.
Sniffer [androidJvm]
typealias Sniffer = suspend (context: SnifferContext) -> MediaType?
Determines if the provided content matches a known media type.
SnifferContext [androidJvm]
class SnifferContext
A companion type of Sniffer holding the type hints (file extensions, media types) and providing an access to the file content.
Sniffers [androidJvm]
object Sniffers
Default media type sniffers provided by Readium.

Functions

Name Summary
sniffMediaType [androidJvm]
suspend fun Response.sniffMediaType(mediaTypes: List<String> = emptyList(), fileExtensions: List<String> = emptyList(), sniffers: List<Sniffer> = MediaType.sniffers): MediaType?
Resolves the format for this Response, with optional extra file extension and media type hints.
[androidJvm]
suspend fun HttpURLConnection.sniffMediaType(bytes: () -> ByteArray? = null, mediaTypes: List<String> = emptyList(), fileExtensions: List<String> = emptyList(), sniffers: List<Sniffer> = MediaType.sniffers): MediaType?
Resolves the format for this HttpURLConnection, with optional extra file extension and media type hints.