0

I try to achieve the following behaviour:

  • Download file from an external location

  • Save it locally

  • Open it

The file-opener plugin seemed to be the perfect match, I used an example from (Opening a remote file): https://plugins.telerik.com/cordova/plugin/file-opener

var fileTransfer = new FileTransfer()
    fileTransfer.download(
     // download from an example pdf
     encodeURI('http://rp.delaat.net/2014-2015/p75/report.pdf'),
     // save to
     'cdvfile://localhost/persistent/test.pdf',
     // open the downloaded file
     function (entry) {
      var file = entry.toURL()
      window.cordova.plugins.fileOpener2.open(
       file,
       'application/pdf',
       {
         error: function (errorMessage) { console.log(errorMessage) },
         success: function () { console.log('succeed') }
       }
    )
  }
)

However on android I get the following error:

file:///data/user/0/nl.mytestapp/files/files/Download/test.pdf exposed beyond app through Intent.getData()

I am using cordova, to deploy my app.

Searching for a solution left me empty handed.

Edit

The error seems to be in opening the file (fileOpener2), only downloading the file goes fine.

M. Suurland
  • 725
  • 12
  • 31

0 Answers0