convertFileSrc

external fun convertFileSrc(filePath: String, protocol: String = definedExternally): String(source)

Convert a device file path to an URL that can be loaded by the webview. Note that asset: and http://asset.localhost must be added to app.security.csp in tauri.conf.json. Example CSP value: "csp": "default-src 'self' ipc: http://ipc.localhost; img-src 'self' asset: http://asset.localhost" to use the asset protocol on image sources.

Additionally, "enable" : "true" must be added to app.security.assetProtocol in tauri.conf.json and its access scope must be defined on the scope array on the same assetProtocol object.

Return

the URL that can be used as source on the webview.

Since

1.0.0

Parameters

filePath

The file path.

protocol

The protocol to use. Defaults to asset. You only need to set this when using a custom protocol.