javascript - 检索从 gmail 下载的文件形式附件的内容,因为它存储在 gmail 服务器中

标签 javascript android cordova phonegap-plugins

我必须从 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/

相关文章:

javascript - 刷新页面后如何查看超链接状态?

android - 如何将 phonegap 应用程序直接部署到设备

android - View 和 subview 之间的区别 - Android

Android - 如何将图像放置在 2 列列表的其中一列中并使图像垂直居中?

javascript - UserModel 不可分配给文档类型的参数 | nulll [带 typescript 的 Mongoose ]

javascript - knockout Accordion 绑定(bind)中断

android - Android 中的通用屏幕尺寸有多大?

javascript - Phonegap 警报对话框在消息顶部显示 index.html

javascript - 使用 CORS 仍然会出现跨源错误

javascript - 在选择菜单的操作中嵌入 2 个参数