1
我嘗試使用Cordova File Transfer插件將圖像下載到我的設備,但每次都收到錯誤代碼1。Cordova文件傳輸錯誤1
這是我的代碼:
var fileTransfer = new FileTransfer();
var fileOrigin = encodeURI('http://cordova.apache.org/images/cordova_bot.png');
//var fileTarget = cordova.file.applicationDirectory + ' image.png'; // Don't work
var fileTarget = 'cdvfile://localhost/persistent/image.png'; // Success, but i don't find the image
//var fileTarget = 'cdvfile://android_asset/image.png'; // Don't work
//var fileTarget = FileEntry.toURL() + 'image.png'; // Don't work and don't create any alert
//var fileTarget = DirectoryEntry.toURL() + 'image.png'; // Don't work and don't create alert
fileTransfer.download(
fileOrigin,
fileTarget,
function(entry){
alert('SUCESS!');
}, function(error){
alert('ERROR: ' + error.code);
alert('Target: ' + error.target);
}
);
alert('Teste');
當我嘗試做一個.toURL fileTarget(),所有的下載腳本不運行,不創建一個警報。
當我嘗試使用「cdvfile://localhost/persistent/image.png」執行fileTarget時,我收到成功消息,但沒有在我的設備中找到圖像文件。
我的錯誤在哪裏? 如何將文件保存在DCIM/MyApp等特定文件夾中?
感謝大家