我必须从 gmail 应用程序中检索内容的文件名。
我得到的内容 uri 类似于
内容://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);
}
});
},
最佳答案
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);
}); }
如果是“content://email-ls/myemail@gmail.com/messages/520/attachments/0.1/BEST/false”案例1。这有效
关于javascript - 检索从 gmail 下载的文件形式附件的内容,因为它存储在 gmail 服务器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45575162/