【问题标题】:retrieve text document content with Docs api JAVA使用 Docs api JAVA 检索文本文档内容
【发布时间】:2012-06-24 04:19:03
【问题描述】:

如何使用 google docs api 在 java 中获取文档内容。这是我的代码。

      MediaContent mc = (MediaContent) entry.getContent();
      String UrlForDownload = mc.getUri()+"&exportFormat=txt&format=txt";
        mc.setUri(UrlForDownload);
    MediaSource ms = client.getMedia(mc);

但我没有获取内容,这是获取内容的正确方式吗? 提前谢谢

【问题讨论】:

    标签: java gdata google-docs-api google-drive-api


    【解决方案1】:

    我不确定是否有使用 Google Docs API 获取导出 URL 的好方法。但是,您可以尝试使用 Drive API v2 中的这个 URL:

    https://docs.google.com/feeds/download/documents/export/Export?id=<docID>&exportFormat=txt
    

    唯一的问题是 URL 应该是模糊的(虽然不太可能很快改变),理论上你应该只使用导出链接,它是 Google Drive API 中文件元数据的一部分:

    "exportLinks": {
      ...
      "text/plain": "https://docs.google.com/feeds/download/documents/export/Export?id=1X24S59c2o4pXW9HkAzG-qnq9uegsLNXfnG_2usiVGDs&exportFormat=txt",
      ...
    

    但为此,您需要使用 Google Drive API 而不是 Google Document List API。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多