我一直在使用来自 Ionic native 的文件传输,它在 Android 上运行良好,但在 iOS 上根本不做任何事情
这是我的代码:
getFile(fileName,url){
let fileTransfer: FileTransferObject = this.transfer.create();
fileTransfer.download(url, this.file.dataDirectory + fileName).then((entry) => {
console.log('entry:',entry)
}, (error) => { console.log(error); });
console.log('file transfer',fileTransfer.onProgress)
var a = fileTransfer.onProgress((progressEvent: ProgressEvent) => {
this.ngzone.run(() => {
console.log(progressEvent.loaded)
});
});
}
这取决于如何派生this.file.dataDirectory。
就我而言,它总是像这样工作.
declare var cordova:any; //on top of file
if (this.platform.is('android')) {
this.fsurl = cordova.file.dataDirectory;
}else{
this.fsurl = cordova.file.documentsDirectory;
}