我从外部网址下载pdf时遇到问题,并将其保存在 Android设备上。到目前为止,我收到了这些错误:
download error source http://bbg.co.tz/wp-content/uploads/2015/03/CC008962_Tanzania-tax-briefing-transfer-pricing_18-11-15.pdf
index.js:227 download error target /Phone/Download
index.js:228 upload error code1
这是我的代码:
function bbgDownload(bbgURL)
{
var fileTransfer = new FileTransfer();
var uri = encodeURI(bbgURL);
fileURL='/Phone/Download'
fileTransfer.download(
uri,
fileURL,
function(entry) {
console.log("download complete: " + entry.toURL());
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
},
false,
{
headers: {
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
}
);
console.log("Please show this URL " + bbgURL);
}
答案 0 :(得分:0)
在fileURL变量中附加文件名。这对我有用,例如:
var fileTransfer = new FileTransfer();
var uri = encodeURI("http://bbg.co.tz/wp-content/uploads/2015/03/CC008962_Tanzania-tax-briefing-transfer-pricing_18-11-15.pdf");
var fileURL = "cdvfile://localhost/persistent/mydir/myPdfFile.pdf";
fileTransfer.download(
uri,
fileURL,
function(entry) {
console.log("download complete: " + entry.toURL());
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
},
false,
{
headers: {
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
}
);