Ionic $cordovaFile using

Hello. everyone. I am a new ionic programmer. I have created a new ionic project. The goal of project is to write png file to android phone. So I have install ngCordova plugin and CordovaFile plugin in my project. And Then I have writed my code.

The canvas already have a one image.

        var v_canvas = document.getElementById("canvas");
        var imageData = v_canvas.toDataURL().replace(/data:image\/png;base64,/,'');

      // WRITE
      $cordovaFile.writeFile("file:///storage/sdcard0/", "test_1.png", imageData, true)
        .then(function (success) {
          // success
          //console.log("path = " + cordova.file.dataDirectory);
          console.log("<<<<<<<< : write file ok");
        }, function (error) {
        console.log("<<<<<<<< : write file error");
          // error

surely , the file(test_1.png) was created on my phone. But the png file is not valid. I can’t open the png file on my phone using gallery. What’s the problem? Please anyone help me. Thanks.

I got the same problem. I found out it doesn’t actually process the Data URI it just writes to an empty file which sadly isn’t going to cut it.

Anyone that can input more towards this problem I would like some advice on how to fix this.