How to use Capacitor's convertFileSrc() instead of Cordova's convertFileSrc()?

Can someone give me an example of how to pull convertFileSrc() from Capacitor instead of using the one from cordova?

I need this because if I use the cordova one, then I cannot run my code in the browser anymore – because cordova.js does not support the browser.

Thanks.

Import Capacitor from @capacitor/core:

import { Capacitor } from '@capacitor/core';

and use it like this:

Capacitor.convertFileSrc('file:///your/file/path');

3 Likes

Thanks! This is not documented anywhere in the Capacitor docs, as far as I can tell.

But, I guess it is documented here, now… :slight_smile:

1 Like

I took this to heart! Documented here: https://capacitorjs.com/docs/basics/utilities#convertfilesrc.

1 Like

This worked for me, thanks.

1 Like