saveToDisk

fun Document.saveToDisk(filename: String, content: ByteArray, mimeType: String? = null)(source)

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

This method extends the global document variable, so you can use it like this:

document.saveToDisk("picture.png", bytes, "image/png")

Parameters

filename

The suggested name of the file to save (users will be given a chance to override it).

content

The content to save.

mimeType

Optional mime type information you can save about the file. For example, if you're saving a PNG image, you could pass in "image/png" here. This information may not be necessary if you're just saving / loading binary or text contents, but it can be useful if you expect something else might consume this file. It will be made available in LoadContext when the file is loaded and will be embedded into the URL returned by loadDataUrlFromDisk.