esd*_*zed 7 copy file move cordova
我试图解决这个文件系统uri如下所示:
/var/mobile/Applications/9483756B-8D2A-42C5-8CF7-8D76AAA8FF2C/Shift.app/iqedata/5977e2e9239649d5a7e3b8a54719679f/06e2b8896e51472789fcc27575631f94.jpg
Run Code Online (Sandbox Code Playgroud)
任何机构都能告诉我如何在PhoneGap中解析这个uri并使用下面显示的方法获取FileEntry吗?
window.resolveLocalFileSystemURI(Url, resOnSuccess, resOnError);
Run Code Online (Sandbox Code Playgroud)
我试图在uri之前添加"file://"或"//"但它不起作用.
谢谢.
Unc*_*ace 14
PhoneGap不允许您读取[APP HASH]/Documents或[APP HASH]/tmp文件夹之外的文件.除非您能找到使用其中一个文件夹中的数据初始化应用程序的方法,否则您必须以另一种方式获取数据.我发现下面的代码可以工作.基本上它将本地文件下载到您的临时文件夹中,并为您提供文件条目.
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, function(fs){
fs.root.getFile("temp", {create: true, exclusive: false},
function(entry){
fileTransfer.download(
Url, // the filesystem uri you mentioned
entry.fullPath,
function(entry) {
// do what you want with the entry here
console.log("download complete: " + entry.fullPath);
},
function(error) {
console.log("error source " + error.source);
console.log("error target " + error.target);
console.log("error code " + error.code);
},
false,
null
);
}, function(){
alert("file create error");
});
}, null);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22464 次 |
| 最近记录: |