1. WPCentral Question's Avatar
    Hi

    I do create an hybrid app using ionic framework and cordova file and file-transfer plugin.

    I point to Downloads directory . Into Android it works fine. Into wp8 it does not download the pdf .

    i try downloading a pdf via native browser just to test it and it works it drop the file into download directory

    i just call it : pdfService.downloadPdf(url, fileName);

    The pdf file does not reach the downloads diretory

    i do refer as : fs.root.getDirectory("Downloads",{
    create: true
    },
    How can i make cordova fiel an file-transfer handle the download of pdf files into windows phone 8.1 ?

    My code is here:

    .service('pdfService', ['$ionicLoading', function($ionicLoading) {

    var lastUrl;
    var lastFileName

    return {
    setParams: function(url, fileName) {
    lastUrl = url;
    lastFileName = fileName;
    },
    getParams: function() {
    return {
    url: lastUrl,
    fileName: lastFileName
    };
    },
    downloadPdf: function(url, fileName) {
    lastUrl = url;
    lastFileName = fileName;
    //var deferred = $q.defer();
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
    fs.root.getDirectory("Downloads",{
    create: true
    },
    function(dirEntry) {
    dirEntry.getFile(lastFileName,
    {
    create: true,
    exclusive: false
    },
    function gotFileEntry(fe) {
    //console.log('gotFileEntry 1'+fe.toURL());
    var p = fe.toURL();
    //console.log("filepath "+p);
    fe.remove();
    ft = new FileTransfer();
    $ionicLoading.show({
    template: 'Downloading'
    });
    ft.download(
    encodeURI(lastUrl),
    p,
    function(entry) { //alert('entry 1 '+entry.toURL()); //d.resolve(entry); //return d.promise;
    window.open(entry.toURL(), '_system', 'location=yes,toolbar=yes,closebuttoncaption=Close PDF,enableViewportScale=yes,fullscreen=no');
    $ionicLoading.hide();
    },
    function(error) {
    alert('Error');
    alert("Download Error Source -> " + error.source);
    },
    false,
    null
    );
    },
    function() {
    alert("Get file failed");
    }
    );
    }
    );
    },
    function() {
    alert("Get file failed"+fe.toURL());
    console.log("Request for filesystem failed");
    });
    },
    load: function(fileName) {
    lastFileName = fileName; //alert("Entrou no metodo load: "+lastFileName);

    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
    fs.root.getDirectory(
    "Downloads",
    {
    create: false
    },
    function(dirEntry) {
    dirEntry.getFile(
    lastFileName,
    {
    create: false,
    exclusive: false
    },
    function gotFileEntry(fe) {
    //alert('Metodo load gotFileEntry '+fe.toURL());//alert(' fe.toURL() '+fe.toURL()); //$scope.imgFile = fe.toURL();//alert(' scope.imgFile '+$scope.imgFile);
    window.open(fe.toURL(), '_system', 'location=no,toolbar=yes,closebuttoncaption=Close,enableViewportScale=yes');
    },
    function(error) {
    $ionicLoading.hide();
    alert("Error getting file");
    }
    );
    }
    );
    },
    function() { //alert("Error requesting filesystem 1 ");
    $ionicLoading.hide();
    alert("Error requesting filesystem 2 ");
    });
    } //scope load
    // }),
    } //return
    }])

    Thanks in advance
    08-14-2015 07:41 AM
  2. Angelo Rigo's Avatar
    Is there anybody who already sucessfuly implements cordova file-tansfer into windows phone 8.1?

    I am using Lumia 635, cordova-file and cordova file-transfer.
    08-19-2015 09:11 AM
  3. Angelo Rigo's Avatar
    Just give up from using cordova file plugin to download and/or load pdf files and opening into the browser if someone could use cordova file into windows phone please let me know how to do it.
    08-21-2015 12:42 PM

Similar Threads

  1. Lumia 950 and 950 XL waterproof?!
    By Mahmoud Hussein in forum Microsoft News & Rumors
    Replies: 13
    Last Post: 09-15-2015, 04:38 AM
  2. How do I install GDR2 on my Lumia 930?
    By Windows Central Question in forum Nokia Lumia 930
    Replies: 1
    Last Post: 08-14-2015, 09:54 AM
  3. Can i use build 10512 as a daily driver on lumia 630 dual sim?
    By Windows Central Question in forum Ask a Question
    Replies: 2
    Last Post: 08-14-2015, 09:52 AM
  4. can't get CORTANA in wp 10512
    By ABD-ALQADER AL-ABDULLAH in forum Windows 10 Mobile Insider Preview
    Replies: 0
    Last Post: 08-14-2015, 07:29 AM
  5. Top Rated Shopping Apps in the Windows 10 Store
    By WindowsCentral.com in forum Windows Central News Discussion
    Replies: 0
    Last Post: 08-14-2015, 07:11 AM
LINK TO POST COPIED TO CLIPBOARD