中似乎什麼也不做什麼我遇到了Phonegap FileTransfer API的問題。目前,我試圖運行下面的示例代碼:Phonegap FileTransfer在android
saveFile: function (filepath,location, filetype) {
console.log("FUNCTION BEING CALLED");
var self = this;
//filepath is path to the internets file
//location is where on the device the file will be stored
var fileTransfer = new FileTransfer();
fileTransfer.download(filepath,self.rootPath + location + '.' + filetype,
function (entry) {
console.log('############# DOWNLOAD WORKS ##############');
console.log("download complete: " + entry.fullPath);
},
function (error) {
console.log('############# DOWNLOAD FAILS ##############');
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
}
)
}
目前,什麼都似乎發生。沒有錯誤被標記,並且回調似乎沒有被解僱。我所得到的是「FUNCTION BEING CALLED」的初始console.log。
我已經雙重檢查過,並且可以確認我包含cordova js文件(cordova-2.4.0.js
)。
如果有問題,我已經在Android模擬器,HTC One X和三星Galaxy S3上嘗試了這一切,所有結果都一樣。
有誰知道可能是什麼原因造成的?
編輯:我也覺得我應該提到它也都運行在Angular JS應用程序中。
嘗試console.log(self.rootPath + location +'。'+ filetype);並檢查你得到了什麼 – 2013-04-05 12:27:26
這給了我'/ test_app/test_pdf.pdf'。我也嘗試過沒有根,這給了我'test_pdf.pdf'。這可能是問題的原因嗎?我需要指定一個特定的路徑嗎? – Sam 2013-04-05 12:45:15
我也嘗試過使用'file:/// sdcard/theFile.pdf',但我仍然沒有任何東西 – Sam 2013-04-05 13:22:25