错误的Android以filetransfer.download(埃罗code 1) [英] error to filetransfer.download in android (erro code 1)
本文介绍了错误的Android以filetransfer.download(埃罗code 1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
document.addEventListener(deviceready',onDeviceReady,假);
传播onDeviceReady(){
//请求永久文件系统
window.requestFileSystem(LocalFileSystem.PERSISTENT,0,fileSystemSuccess,fileSystemFail);
}
功能fileSystemSuccess(文件系统){
VAR的DirectoryEntry = fileSystem.root; //获取根目录的路径
directoryEntry.getDirectory(teste_recev,{创建:真实,独家:假},onDirectorySuccess,onDirectoryFail);
VAR ROOTDIR = fileSystem.root;
变种FP = rootdir.fullPath;
FP = FP +/ teste_recev / image_name.jpg;
VAR文件传输=新的文件传输();
fileTransfer.download("https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/t1.0-1/c14.4.48.48/150734_264955536974736_682293823_t.jpg",fp,
功能(输入){
警报(下载完成:+ entry.fullPath);
},
功能(错误){
警报(下载错误源+ error.source);
警报(下载错误的目标+ error.target);
警报(上传错误code+错误code);
}
);
}
功能onDirectorySuccess(父){
执行console.log(父);
}
功能onDirectoryFail(错误){
警报(无法创建新的目录:+错误code);
}
功能fileSystemFail(EVT){
的console.log(evt.target.error code);
}
,但有一个错误:
- 在下载中心误差源<一href="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/t1.0-1/c14.4.48.48/150734_264955536974736_682293823_t.jpg" rel="nofollow">https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/t1.0-1/c14.4.48.48/150734_264955536974736_682293823_t.jpg
- 在下载错误的目标// teste_recev / image_name.jpg
- 上传错误code1
我有,在项目cordova.js,有链接,cordova.js,但有这样的误差修改,如果有人帮忙,真的AP preciate吧。
解决方案
试试这样
window.requestFileSystem(LocalFileSystem.PERSISTENT,0,功能gotFS(文件系统){
fileSystem.root.getDirectory(你的目录,{创建:真},功能fileSystemSuccess(文件系统){
fileSystem.getFile(dummy.txt,{创建:真实,独家:假},功能gotFileEntry(fileEntry){
VAR路径= fileEntry.fullPath.replace(dummy.txt,);
fileEntry.remove();
VAR文件传输=新的文件传输();
fileTransfer.download(FILE_DOWNLOAD_URL,路径++您的-savedName,功能(theFile){
警报(文件成功下载+ theFile.toURI());
},功能(错误){
警报(文件传输失败+返回Error.message);
});
},失败);
});
}, 失败);
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
//request the persistent file system
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, fileSystemSuccess, fileSystemFail);
}
function fileSystemSuccess(fileSystem) {
var directoryEntry = fileSystem.root; // to get root path to directory
directoryEntry.getDirectory("teste_recev", {create: true, exclusive: false}, onDirectorySuccess, onDirectoryFail);
var rootdir = fileSystem.root;
var fp = rootdir.fullPath;
fp = fp+"/teste_recev/image_name.jpg";
var fileTransfer = new FileTransfer();
fileTransfer.download("https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/t1.0-1/c14.4.48.48/150734_264955536974736_682293823_t.jpg",fp,
function(entry) {
alert("download complete: " + entry.fullPath);
},
function(error) {
alert("download error source " + error.source);
alert("download error target " + error.target);
alert("upload error code" + error.code);
}
);
}
function onDirectorySuccess(parent) {
console.log(parent);
}
function onDirectoryFail(error) {
alert("Unable to create new directory: " + error.code);
}
function fileSystemFail(evt) {
console.log(evt.target.error.code);
}
But have a error:
- dowload error source https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/t1.0-1/c14.4.48.48/150734_264955536974736_682293823_t.jpg
- download error target//teste_recev/image_name.jpg
- upload error code1
i have, the cordova.js in project, have link for cordova.js but have this erros if someone to help, really appreciate it.
解决方案
Try like this
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function gotFS(fileSystem) {
fileSystem.root.getDirectory("your dir", {create: true}, function fileSystemSuccess(fileSystem){
fileSystem.getFile("dummy.txt",{create: true,exclusive:false},function gotFileEntry(fileEntry){
var path = fileEntry.fullPath.replace("dummy.txt","");
fileEntry.remove();
var fileTransfer = new FileTransfer();
fileTransfer.download(FILE_DOWNLOAD_URL, path+""+your -savedName,function(theFile){
alert("File Downloaded Successfully " + theFile.toURI());
},function(error){
alert("File Transfer failed" + error.message);
});
},fail);
});
}, fail);
这篇关于错误的Android以filetransfer.download(埃罗code 1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文