Я столкнулся с некоторыми проблемами при использовании плагина Cordova File Transfer. Это мой код:
window.requestFileSystem(
LocalFileSystem.PERSISTENT,
0,
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
"dummy.html", {create: true, exclusive: false},
function gotFileEntry(fileEntry) {
var sPath = fileEntry.fullPath.replace("dummy.html", "");
var fileTransfer = new FileTransfer();
fileEntry.remove();
fileTransfer.download( 'http://cordova.apache.org/images/cordova_bot.png', sPath + photo.original_name,
function (theFile) {
alert('success: ' + JSON.stringify(theFile));
console.log("download complete: " + theFile.toURI());
// showLink(theFile.toURI());
},
function (error) {
alert('error: ' + JSON.stringify(error));
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code: " + error.code);
},
true
);
})
},
function (error) {
alert('error request: ' + JSON.stringify(error));
}
);
Обратный вызов ошибки fileTransfer.download возвращается с кодом ошибки 3, http 401. Я уже обновил плагины File и FileTransfer, моя версия Cordova — 4.3.0. Также проверил мой config.xml для
<access origin="*" />
но он есть. Я попытался добавить заголовок Connection: close, но безрезультатно. Пробовал также установить 4-й параметр загрузки по умолчанию (false) - не повезло.
Тестирование на планшете Android.
Кто-нибудь что-нибудь? Спасибо!
cordova plugin add [email protected]
, чтобы добавить указанную версию. 20.04.2015