How to download image from url and save in desire folder in capacitor

Good day,

I am trying to download an image and save it into desired folder. For this, I am using capacitor filesystem.

Here is my code:

async fileWrite(fileUrl,name) {
    try {
      const result = await Filesystem.writeFile({
        path: name,
        data: fileUrl,
        directory: FilesystemDirectory.Data,
        encoding: FilesystemEncoding.UTF8
      console.log('file Downloaded', result);
    } catch(e) {
      console.error('Unable to write file', e);

  async readFile(pth,name){
      encoding: FilesystemEncoding.UTF8,
      path: pth
      result => {
        // let path = Capacitor.convertFileSrc(result.uri);
        // console.log(path);
        this.src =;
      err => {

Calling function like this:

<img src='{{src}}'>
  <button (click)="fileWrite('','dummyImage.jpg')">Downloads</button>

What the above code does:
It does show the image but not with the local url (using webURL), although I passed the local url to read it.
What I am doing wrong ??