|
WebX5版本3.6,采用模式三打包调试(使用UIServer)使用fileApi.download下载文件,使用fileApi.browser访问文件,关于文件在app上所在的目录问题,有如下疑问:
下载代码如下:
fileApi.download(url,fileFullPath).done(function(entry){
console.log("**index,fileApi.download,nativeUrl="+entry.toURL()+",name="+entry.name+",fullPath="+entry.fullPath);
fileApi.browse(entry.toURL());})
.fail(function(error){
console.log("**index,fileApi.download fail "+error.code)
});
其中url=http://192.168.0.12:8080/x5/docs/huiyi-test.m.docx
1.当fileFullPath = file:///storage/emulated/0/lyhyfiles/0311/huiyi-test.m.docx,上述代码执行正确,即可以正常下载并打开(通过app上的wps打开文件,直接显示文件内容)
2.fileFullPath = cordova.file.applicationDirectory + 'huiyi-test.m.docx',download失败,errcode=1,应该对应的 FileError.NOT_FOUND_ERR ,文件不存在? 相对1来说,只是 fullPath不同
日志跟踪,发现cordova.file.applicationDirectory = file:///android_asset/,不知道在app上对应哪个目录
3.当fileFullPath=cordova.file.applicationStorageDirectory+ 'huiyi-test.m.docx',download执行正常,但browse直接进入wps首页(找不到huiyi-test.m.docx文件)。正常应该调用wps直接打开文件
日志跟踪,发现cordova.file.applicationStorageDirectory = file:///data/user/0/com.lyhy.hy0310/,但app上找不到/data/user/0目录啊。。。,可以找到的com.lyhy.hy0310在Anroid/data目录下,但该目录下也没有下载的文件。。。。但用applicationStorageDirectory,download显示成功,只是不知道文件下载到什么地方了?
另外,利用fileApi.getFile,获得fs.root = file:///data/user/0/com.lyhy.hy0310/cache/,把上述download参数filefullpath换成 fs.root.toURL() + 'lyhyfiles/' + td + "/" + fName,结果同 applicationStorageDirectory,即下载正常,文件不能访问。。
另外,通过谷歌浏览器进行真机测试,日志显示有时候出现不全现象,如下,destpath的值未显示全。附图是另外一个日志未全的截图。
**this.download,fs.root=file:///data/user/0/com.lyhy.hy0310/cache/,destPath=file:///data/user/0/com…2Fhuiyi-test-m.docx,url=http://192.168.0.12:8080/x5/docs/huiyi-test-m.docx
截图中的“console.js:7 No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.”错误,应该如何处理?
|
|