javascript - PhoneGap File Transfer Error 1, where to write FileTransfers? -


related to: https://stackoverflow.com/questions/21044197/download-file-and-store-them-locally-in-sdcard-using-phonegapbuild questions has never been answered.

about app, i'm writing little app displays bunch of pdf's, it's written using jquerymobile + phonegap , it's being build phonegap build service.

i realize function cannot work, since root-directory not valid place write anything. but, unable working directory of application, nor able figure out error code 1 meant using documentation.

from config.xml:

 <preference name="androidpersistentfilelocation" value="internal" />  <preference name="permissions" value="none" /> <feature name="http://api.phonegap.com/1.0/file"/> <feature name="http://api.phonegap.com/1.0/device" />   <gap:plugin name="org.apache.cordova.file" /> <gap:plugin name="org.apache.cordova.file-transfer" /> 

and build service tells me these plugins have been sucessfully added.

unpacking apk , looking manifest reveals

 <uses-permission android:name="android.permission.write_external_storage" /> 

was added.

last not least phonegap library added document using

<script type="text/javascript" charset="utf-8" src="phonegap.js"></script> 

and there actual function left blame:

function downloadfile(name, url, y,x, canvasid, wrapperid){    alert(name);    window.requestfilesystem(localfilesystem.persistent, 0,    function(filesystem) {       var directoryentry = filesystem.root; // root path directory       var rootdir = filesystem.root;       var fp = rootdir.fullpath;       fp = fp+"/bestsongs/"+name;       alert("downloading: " + url + " " + fp);       var filetransfer = new filetransfer();       alert("downloading: " + url + " " + fp);       filetransfer.download(             url,             name,             function(thefile) {                   alert("download complete: " + thefile.touri());                   loadpdf(thefile.touri(), y,x, canvasid, wrapperid);       },function(error) {             alert("error: " + json.stringify(error));       }    );    },     function(arg) {        alert("fail on requestfilesystem" + json.stringify(arg)); }   ); }   $(function() { document.addeventlistener("deviceready", function() {        alert("deviceready!");        try {            alert(url);            downloadfile(lyrics,url,y,x, 'the-canvas', 'wrapper');        } catch(e) {            alert(e);        } }, false); }); 

using alerts, here get:

deviceready! <url> file (which right) name of file. downloading <url> //bestsongs/<name> downloading <url> //bestsongs/<name> error: {         "code":1,          "source":<url>,          "target":<name>,          "http_status": null,          "body": null        } 

i have been debugging days, please have solution.

hey take @ answer on here -

phonegap - save image url device photo gallery

and let me know. if there still problem. include following in config.xml

for android -

<feature name="http://api.phonegap.com/1.0/file" /> <feature name="file">        <param name="android-package" value="org.apache.cordova.file.fileutils" /> </feature> <feature name="filetransfer">       <param name="android-package" value="org.apache.cordova.filetransfer.filetransfer" /> </feature> <feature name="storage">        <param value="org.apache.cordova.storage" name="android-package"/> </feature> 

for ios-

<plugin name="file" value="cdvfile" /> <plugin name="filetransfer" value="cdvfiletransfer" /> 

for checking network connection available or not add following in config.xml - add permissions in plugin.xml , plugins name in config.xml

plugin check network connection android -

<uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.read_phone_state" /> <plugin name="networkstatus" value="org.apache.cordova.networkmanager" /> 

for ios -

<plugin name="networkstatus" value="cdvconnection" /> 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -