javascript - Navigate to download folder for android, iOS, and Windows with cordova -


so i've tried multiple ways navigate default folder downloads on listed os. i'll include comment below show i've tried. i've been trying use file, filetransfer, , fileopener2 plugins. know folders different on each os , android can more particular i'd satisfied generic folder documents. detect os app on, , based on that, navigate right folder. in theory @ least. right way or there more efficient way?

thanks.

var os = detectos(); if (os=='ios'){     //here need:     // var set directory finding code ---- part different per os     // string search function files 'bap'     //if statement return name of file if 1 file, array if mult. files, , null or 0 if no file   } else if (os=='android'){     //file dir = environment.getexternalstoragepublicdirectory(environment.directory_downloads);    // console     //var windowlocation = window.location.href;     //var downloadloc = "../internal storage/download";     //windowlocation.tourl(downloadloc);     //window.requestfilesystem(window.temporary, 5*1024*1024 /*5mb*/, oninitfs, errorhandler);     //var newlocationurl = window.resolvelocalfilesystemurl(windowlocation);    //alert(window.parent);    //alert("is working??");   // var testpathstring = getexternalstoragedirectory();    //console.log(testpathstring);    //var anothertest = cordova.file.externaldatadirectory;   // alert(anothertest);    //we're trying different approach     //function downloadpdf() {             var filetransfer = new filetransfer();             //var inputuri = encodeuri("http://nextwavesoftware.com/downloads/helloworld.pdf");             //var outputpath = cordova.file.externaldatadirectory + "helloworld.pdf";             //alert (outputpath);             // var outputpath = "/storage/emulated/0/download/helloworld.pdf";             /*alert("starting download " + outputpath);             filetransfer.download(                   inputuri,                   outputpath,                 function (entry) {                     alert("download complete: " + entry.fullpath + ", url=" + entry.tourl());                     cordova.plugins.fileopener2.open(                         entry.tourl(), // can use cordova-style file uri: cdvfile://localhost/persistent/download/starwars.pdf                         'application/pdf',                         {                             error: function (e) {                                 alert('fileopener2 error status: ' + e.status + ' - error message: ' + e.message);                             },                             success: function () {                                 alert('fileopener2 file opened successfully');                             }                         }                     );                 },                 function (error) {                     alert("download error: source=" + error.source + ", target=" + error.target + ", error code=" + error.code);                 });*/        //}         //another approach       /* if(/bap/.test(window.location.href)){            alert("file found!");        } else {            alert("file not found, code working!");        }*/  } else if (os=='windows'){     //file path = environment.getexternalstoragepublicdirectory();     //var testpathstring = getexternalstoragedirectory();     //console.log(testpathstring);     //var test1 = window.location;     //requestfilesystem(localfilesystem.persistent, 0, onsuccess, onerror);     //console.log(test1);     //var filelocation = "file:///c:/downloads";     // window.requestfilesystem(window.temporary, 5*1024*1024 /*5mb*/, oninitfs, errorhandler);     //window.resolvelocalfilesystemurl(filelocation);     //alert(cordova.file.applicationstoragedirectory);     //alert(filelocation);     //alert(cordova.file.datadirectory);  } 


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -