Package-level declarations

Types

Link copied to clipboard
class FileErrorException(val file: File) : FileException
Link copied to clipboard
abstract class FileException(val file: File, message: String) : Throwable
Link copied to clipboard
class LoadContext(val filename: String, val mimeType: String?, val event: ProgressEvent)
Link copied to clipboard
class LoadedFile<O>(val context: LoadContext, val contents: O)

Functions

Link copied to clipboard
fun Document.loadDataUrlFromDisk(accept: String = "", onError: LoadContext.() -> Unit = {}, onLoad: LoadContext.(String) -> Unit)

Like loadFromDisk but specifically loads some content from disk as a URL with base64-encoded data.

Link copied to clipboard
fun Document.loadFromDisk(accept: String = "", onError: LoadContext.() -> Unit = {}, onLoad: LoadContext.(ByteArray) -> Unit)

Load some binary content from disk, presenting the user with a dialog to choose the file to load.

Link copied to clipboard
fun Document.loadMultipleDataUrlFromDisk(accept: String = "", onError: (List<LoadContext>) -> Unit = {}, onLoad: (List<LoadedFile<String>>) -> Unit)
Link copied to clipboard
fun Document.loadMultipleFromDisk(accept: String = "", onError: (List<LoadContext>) -> Unit = {}, onLoad: (List<LoadedFile<ByteArray>>) -> Unit)

Like loadFromDisk but allows loading multiple files at once.

Link copied to clipboard
fun Document.loadMultipleTextFromDisk(accept: String = "", encoding: String = "UTF-8", onError: (List<LoadContext>) -> Unit = {}, onLoad: (List<LoadedFile<String>>) -> Unit)
Link copied to clipboard
fun Document.loadTextFromDisk(accept: String = "", encoding: String = "UTF-8", onError: LoadContext.() -> Unit = {}, onLoad: LoadContext.(String) -> Unit)

Like loadFromDisk but convenient for dealing with text files.

Link copied to clipboard
suspend fun File.readBytes(): ByteArray

Read the contents of a file as a ByteArray, suspending until the read is complete.

fun File.readBytes(onError: () -> Unit = {}, onLoad: (ByteArray) -> Unit)

Read the contents of a file as a ByteArray, asynchronously.

Link copied to clipboard
fun Document.saveTextToDisk(filename: String, content: String, mimeType: String? = null)

A convenience method to call saveToDisk with a String instead of a ByteArray.

Link copied to clipboard
fun Document.saveToDisk(filename: String, content: ByteArray, mimeType: String? = null)

Save some content to disk, presenting the user with a dialog to choose the file location.