1

In my sencha touch app I have a pdf file saved in my resources folder. When I package the app with cordova the file gets packed correctly in the www folder.

Then, when the user taps a button, I need to save this file from the resources folder to the device storage(in my app documents folder on iOS) in order to get this file opened from an external app using the cordova file opener 2 plugin.

If I download a file from an external address it works perfectly, but I can't access the file from my resources folder, someone can help?

Here is the code I use to download the file to my app documents folder:

downloadFile: function (url, filename) {
    var me = this;
    var encodedUrl = encodeURI("http://www.analysis.im/uploads/seminar/pdf-sample.pdf");
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs){

        var fileURL = "cdvfile://localhost/persistent/" + filename;

        var fileTransfer = new FileTransfer();

        fileTransfer.download(
            encodedUrl,
            fileURL,
            function(entry) {
                me.openFile(entry.toURL());//method to open the file with a third app
                console.log("download complete: " + entry.toURL());
                console.log("download complete: " + entry.fullPath);
            },
            function(error) {
                console.log("upload error: " + JSON.stringify(error));
            },
            false,
            {
                headers: {
                    "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
                }
            }
        );
    }, null);
}

I can't find a way to access the resources folder instead of the external URL, I tried to use the url starting with /resources/blablabla, resources/blablabla, /www/resources/blablabla with no luck, someone can help?

allemattio
  • 1,836
  • 17
  • 33

0 Answers0