82806

Phonegap fileTransfer.Download is not working on ios phonegap 3.0

Question:

I am developing an app with JQM and then using build.phonegap.com, i am building the app.

I have a feature to download the audio file from the server and then play it in the app.

it is working perfectly in android.

I tried all possibilities to make it work.

can some one help on this.

here is my complete file handling code

fileSystem.root.getDirectory("auidofiles", { create : true, exclusive : false }, function(dirEntry) { dirEntry.getFile(mp3_file, { create : false, exclusive : false }, function(fileEntry) { alert("File Already downloaded"); if (device.platform == "Android") { FILEPATH = fileEntry.fullPath; //FILEPATH = fileEntry.toURI(); playAudio(); } else { var filePathLocal1 = getPhoneGapPath() + "auidofiles/" + mp3_file; //var filePathLocal = fileSystem.root.toURL() + "auidofiles/" + mp3_file; //alert("Ios File Path:" + filePathLocal); //FILEPATH = filePathLocal; //FILEPATH = fileEntry.fullPath; //FILEPATH = fileEntry.toURI(); playAudio(); } }, function(fileFail) { alert("File Not found"); var ft = new FileTransfer(); ft.onprogress = function(progressEvent) { if (progressEvent.lengthComputable) { var perc = Math.floor(progressEvent.loaded / progressEvent.total * 100); $('#downloadStatus').html(perc + "% loaded..."); } else { if ($('#downloadStatus').html() == "") { $('#downloadStatus').html("Loading"); } else { $('#downloadStatus').html( $('#downloadStatus').html() + "."); } } }; //ft.Progress var filePathLocal = fileSystem.root.toURL() + "auidofiles/" + mp3_file; ft.download(audioStreamUrl, filePathLocal, function(entry) { //alert("File = " + entry.toURI()); if (device.platform == "Android") { FILEPATH = entry.fullPath; //FILEPATH = entry.toURI(); playAudio(); } else { var filePathLocal1 = getPhoneGapPath() + "auidofiles/" + mp3_file; //alert("Ios File Path:" + filePathLocal); FILEPATH = filePathLocal; //FILEPATH = entry.fullPath; //FILEPATH = entry.toURI(); playAudio(); } }, function(error) { $('#downloadStatus').html( "download error source " + error.source); $('#downloadStatus').html( "download error target " + error.target); $('#downloadStatus').html("upload error code" + error.code); }); //ft.Download }); //getFile End }, function(dirfail) { alert("dirfail"); alert(JSON.stringify(dirfail)) $('#downloadStatus').html(JSON.stringify(dirfail)); }) function getPhoneGapPath() { var path = window.location.pathname; path = path.substr( 0, path.length - 10 ); return 'file://' + path;

};

Answer1:

There is a new requirement to use .toURL() instead of .fullPath

This fixes the majority of these type of problems - however I have experienced a similar problem using older versions of the iOS (5.x) where filetransfer.download never fires success/fail/progress events even though it does actually download the file. I then get an app crash when I try to restart the app...

Answer2:

I had the same issue and fixed it with <strong>downgrading the Cordova Plugin FileTransfer from v0.4.2 to v0.3.3 while using Phonegap/Cordova v3.3</strong>.

Recommend

  • can not play ogg on android
  • Phonegap fileTransfer.Download is not working on ios phonegap 3.0
  • Where is the file sandbox for a Chrome app?
  • Saving image to SD Card in a Worklight application
  • Loading resources from html5 filesystem api
  • How to use active record reputation gem with many to many relationship
  • Putting separate ranges into 2D array
  • Include in project programmatically
  • How to set user avatar for Navigation drawer via url in android?
  • Setting php.ini variables inside web.config on IIS 7.5
  • Store ArrayList into SharedPreferences
  • Java/JavaFX: Set Swing Icon for JavaFX label
  • Elastic Beanstalk failed to update local Git configuration - Windows
  • Find the associated program to open a file using Java
  • C++ slows over time reading 70,000 files
  • On which thread JavaFX change listeners are executed ?
  • The symbol you provided is not a function
  • Consuming a web service with the Netbeans Platform
  • How to handle empty space in url when downloading image from web?
  • How to use Windows Media Foundation with UWP without a topology
  • Code in Job's Script Block after Start-Process Does not Execute
  • x64 applications using gdi+: what are the consequences on performance?
  • Disable Enter in editText android
  • Cannot resolve symbol 'MyApi'
  • If I include Java 8 in my Android app does that affect which devices it will work on?
  • Release, debug version and Authorization Google?
  • How to delete a row from a dynamic generate table using jquery?
  • using HTMLImports.whenReady not working in chrome
  • Authorize attributes not working in MVC 4
  • EntityFramework adding new object to nested object collection