DEV Community

Discussion on: How To Use Ionic Native Plugins In React Capacitor Mobile Application

Collapse
 
eichgi profile image
Hiram

I am experiencing this issue:

error FileTransferError {code: 3, source: "postfun.com/wp-content/uploads/201...", target: "file:///android_asset/file.jpg", http_status: 401, body: null, …}

Do you have an idea why?

the following is my code:

download() {
      console.log("download");
      let fileTransfer = FileTransfer.create();
      const url = "https://www.postfun.com/wp-content/uploads/2019/09/Hickory-horned-devil-82819.jpg";
      fileTransfer.download(url, File.applicationDirectory + "file.jpg", true, {mode: 'no-cors'})
          .then(async entry => {
                console.log("download complete: " + entry.toURL());
                // need to convert url so you don't get permission errors...
                this.image = (Capacitor.convertFileSrc(File.tempDirectory + "file.jpg"));
              },
              error => {
                // handle error
                console.log("error", error);
              })
          .catch(error => {
            console.log("ERROR: ", error);
          });
    },
Enter fullscreen mode Exit fullscreen mode
Collapse
 
arushnath profile image
ArushNath

I am also facing this issue, did you find any solution?