2016-04-18 5 views
0

i in cordova bin neu und ionischewie Datei in ionischer und cordova mit File-Transfer zum Download (nur Dateisystemfehler lesen)

i Audio-Datei vom Server

meine ionische Version herunterladen möchten: 1.7.14

meine cordova Version ist: 6.1.1

meine android-Version ist: 6 (I encrypt Modus)

hier mein Code:

$scope.DownloadFile = function (url, filename) { 

var ft = new FileTransfer(); 
    var source = encodeURI('http://' + url + filename); 
    var targetPath = cordova.file.documentsDirectory + filename;//change path as you need 
    var trustHosts = true;//optional 
    var options = {};//optional 
    ionic.Platform.ready(function() {//device prepared 
    ft.download(source, targetPath, function (entry) { 
     alert('success' + JSON.stringify(entry)); 
    }, function (err) { 
     alert(url + filename); 
     alert(JSON.stringify(err)); 
    }, trustHosts, options); 
    }); 
} 

ich dieses Ergebnis:

{"code":1 , "source":"http://sedaban.com/sedaban/users/json/app/mobile/download/146012022293952.mp3","target":"null146012022293952.mp3","http_status":200,"body":null,"exception":"/null146012022293952.mp3:open failed: EROFS (Read-only file system)"} 

Antwort

0

cordova.file.documentsDirectory für Android nicht gültig ist.

Dies ist die Beschreibung in cordova Datei-Plugin github - "cordova.file.documentsDirectory - Dateien privat für die App, aber die für andere Anwendung (z. B. Office-Dateien) sinnvoll sind. Beachten Sie, dass für OSX ist der Benutzer ~/Documents-Verzeichnis (iOS, OSX) "

Testen Sie cordova.file.externalDataDirectory oder cordova.file.externalRootDirectory für Android. Hoffe es hilft

+0

Ich benutze diese cordova.file.externalRootDirectory jetzt bekomme ich das (EACCES (Berechtigung verweigert) ... und cordova.file.externalDataDirectory gib mir nichts –

+0

@amirbaqdadi da du android Marshmalliow verwendest, musst du das verwenden neuste Version von cordova file plugin (4.2.0) wie die ältere Version hat Probleme mit dem Zugriff auf Ordner mit Android marshamallow – Gandhi

Verwandte Themen