convertFileSrc
Convert a device file path to a URL that can be loaded by the webview.
The asset protocol must be enabled and the files you want to expose must be included in its scope. The protocol origins must also be allowed by the relevant app.security.csp directive. For example, this configuration allows images from the user's downloads directory:
{
"app": {
"security": {
"assetProtocol": {
"enable": true,
"scope": ["$DOWNLOAD/**"]
},
"csp": "default-src 'self'; img-src 'self' asset: http://asset.localhost"
}
}
}Content copied to clipboard
See assetProtocol for the available scope variables and platform-specific protocol details.
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.