AssetRetriever

Retrieves an Asset instance providing reading access to the resource(s) of an asset stored at a given Url as well as its Format.

Constructors

Link copied to clipboard
constructor(resourceFactory: ResourceFactory, archiveOpener: ArchiveOpener, formatSniffer: FormatSniffer)
constructor(contentResolver: ContentResolver, httpClient: HttpClient)

Types

Link copied to clipboard
sealed class RetrieveError : Error

Error while trying to retrieve an asset from a Resource or a Container.

Link copied to clipboard
sealed class RetrieveUrlError : Error

Error while trying to retrieve an asset from an URL.

Functions

Link copied to clipboard
suspend fun retrieve(file: File, formatHints: FormatHints = FormatHints()): Try<Asset, AssetRetriever.RetrieveError>
suspend fun retrieve(file: File, mediaType: MediaType): Try<Asset, AssetRetriever.RetrieveError>

Retrieves an asset from a local file.

Retrieves an asset from an url and a known format.

suspend fun retrieve(url: AbsoluteUrl, formatHints: FormatHints = FormatHints()): Try<Asset, AssetRetriever.RetrieveUrlError>

Retrieves an asset from an AbsoluteUrl.

suspend fun retrieve(container: Container<Resource>, hints: FormatHints = FormatHints()): Try<Asset, AssetRetriever.RetrieveError>

Retrieves an asset from an already opened container.

suspend fun retrieve(resource: Resource, hints: FormatHints = FormatHints()): Try<Asset, AssetRetriever.RetrieveError>
suspend fun retrieve(resource: Resource, mediaType: MediaType): Try<Asset, AssetRetriever.RetrieveError>

Retrieves an asset from an already opened resource.

Link copied to clipboard
suspend fun sniffFormat(file: File, hints: FormatHints = FormatHints()): Try<Format, AssetRetriever.RetrieveError>

Sniffs the format of a file content.

suspend fun sniffFormat(url: AbsoluteUrl, hints: FormatHints = FormatHints()): Try<Format, AssetRetriever.RetrieveUrlError>

Sniffs the format of the content available at url.

suspend fun sniffFormat(container: Container<Resource>, hints: FormatHints = FormatHints()): Try<Format, AssetRetriever.RetrieveError>

Sniffs the format of a container content.

suspend fun sniffFormat(resource: Resource, hints: FormatHints = FormatHints()): Try<Format, AssetRetriever.RetrieveError>

Sniffs the format of a resource content.