1
我嘗試使用Phonegap Build創建一個應用程序,同時使用多個插件爲了將在線文件下載到設備的SD卡。利用以下鏈接:從Cordova的FileTransfer下載不完整的文件
我)https://www.tutorialspoint.com/cordova/cordova_file_transfer.htm II)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);
});
}
無論其問題是雖然獲得成功Callback,該文件只有部分下載。 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="*" />
我試着尋找答案,但到目前爲止它似乎沒有其他人多少都遇到過這樣的錯誤。我哪裏錯了?/我做了什麼錯誤?