Search code examples
cordovaionic2transferionic3

code:3, Return on connection error CONNECTION_ERR in Transfer plugin


I am trying to download an pdf file form transfer plugin

fileTransfer.download(url+'?token=XXXXXX121b42867f03b7f1701e8f8656566a5', this.file.dataDirectory + file.filename).then((entry) => {
        loader.dismiss();

        console.log('download complete: ' + entry.toURL());

      }, (error) => {
        // handle error

        console.log(error);
        console.log('ERROR');


      });

i am always invoking error part of my transfer plugin.

I know it is something to do with my token i have tried my best but i wanted to know am i passing my token correctly an why i am always invoking error part.


Solution

  • i was getting the file name as demo sample.pdf because of that space i was invoking error part

    solution is encodeURI(url)

    fileTransfer.download(encodeURI(url+'?token=XXXXXX121b42867f03b7f1701e8f8656566a5'), this.file.dataDirectory + file.filename).then((entry) => {
            loader.dismiss();
    
            console.log('download complete: ' + entry.toURL());
    
          }, (error) => {
            // handle error
    
            console.log(error);
            console.log('ERROR');
    
    
          });