FileTransfer Plugin do not work on browser


#1

Hi everyone,

I am trying to download a file with the FileTransfer native plugin in a desktop browser and mobile browser, but I get this error in both platforms (Browser/Android Chrome):

body:null
code:1
exception:null
http_status:null
source:"./assets/docs/Contrat_base.pdf"
target:"filesystem:file:///persistent/contrat.pdf"

I am running the ionic cordova run browser command to test this part of the application.

Here is the code:

let url = './assets/docs/Contrat_base.pdf'; // It can be a S3 bucket link

const fileTransfer: FileTransferObject = this.transfer.create();

fileTransfer.download(url, this._file.dataDirectory + "/contrat.pdf", true, {
   fileName: "contrat.pdf"
}).then((entry) => {
   console.log('download complete: ' + entry.toURL());
}, (error) => {
   console.log("ERROR:", error);
 });

How can I download the file? Do I need different methods for each type of platform?

Please help me!

Thanks in advance!


#2

This blog post would be of interest to you: Transition off of cordova-plugin-file-transfer