我必须从gmail app中检索内容的文件名。
我得到的内容类似于
内容://gmail-ls/messages/gaddam40gmail.com/4/attachments/0.1/BEST/false
我正在写这个uri,但它会出错,我需要做什么
window.plugins.webintent.getUri(function(url) {
if(url.startsWith('content://')) {
// url is the url the intent was launched with
//alert(url);
window.FilePath.resolveNativePath(url, function(local)
{ //deferred.resolve('file://'+local)
alert(url);
},function (error)
{
alert(error.message);
}
);
alert("passing");
//var path = converted_url.slice(0, converted_url.lastIndexOf('/') + 1);
//var filename = converted_url.substring(converted_url.lastIndexOf('/') + 1);
//alert(filepath);
}
});
},
答案 0 :(得分:1)
window.plugins.webintent.getUri(function(url) {
if(url.startsWith('content://')) {
window.resolveLocalFileSystemURL(url, success, fail);
function success(fileEntry){
alert("present");
fileEntry.file(function(file){
alert("is")
var ft=new FileReader();
ft.onloadend=function(e){
// Do something
}
ft.readAsText(file);
}); }
如果是" ontent://gmail-ls/myemail@gmail.com/messages/520/attachments/0.1/BEST/false"案例1.这是有效的