从Cordova的FileTransfer下载不完整的文件

时间:2017-03-05 01:22:19

标签: android cordova phonegap-build file-transfer

我正在尝试使用Phonegap Build创建一个应用程序,同时使用多个插件将在线文件下载到设备的SD卡。利用以下链接:

i)https://www.tutorialspoint.com/cordova/cordova_file_transfer.htm ⅱ)https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file-transfer/index.html#download

我能够让这段代码起作用:

function downloadFile() {


 var fileTransfer = new FileTransfer();
  fileTransfer.download(
"http://developer.android.com/assets/images/home/ics-android.png",
"file:///storage/sdcard0/aw2uin.png",
function(entry) {
    alert("download complete: 1" + entry.toURL);
},
function(error) {
    alert("download error source " + error.source);
    alert("download error target " + error.target);
    alert("upload error code" + error.code);
});

}

问题在于,虽然获得了successCallBack,但该文件仅部分下载。 Eg.ics-android.png:这个文件大小为14.7kB,但结果的大小为0B。另一个125kB文件的例子导致下载104.55kB。 我的config.xml具有以下权限:

<plugin name="cordova-plugin-file" spec="~4.3.1" />
<plugin name="cordova-plugin-file-transfer" spec="~1.6.1" />
<plugin name="cordova-plugin-network-information" spec="~1.3.1" />
<plugin name="cordova-plugin-whitelist" version="1.3.1" />
<access origin="*" /><!--subdomains="true" /> -->
<preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,assets,root" />
<preference name="android-minSdkVersion" value="7" />
<preference name="android-installLocation" value="preferExternal" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-navigation href="*" />  

我已经尝试过寻找答案,但到目前为止,其他人似乎没有遇到过这个错误。我哪里出错?/我做错了什么?

1 个答案:

答案 0 :(得分:0)

管理让我为此工作:

{{1}}