【问题标题】:Google Drive Rest Api Files export limitationGoogle Drive Rest Api 文件导出限制
【发布时间】:2016-11-30 14:11:23
【问题描述】:

我使用rest api "https://www.googleapis.com/drive/v3/files/fileId/export" "reference page" 来获取google Doc

当我尝试获取文件时,文档大小约为 5 MB,但出现 json 错误:

{
  "error": {
    "errors": [
      {
        "domain": "global",
        "reason": "exportSizeLimitExceeded",
        "message": "This file is too large to be exported."
      }
    ],
    "code": 403,
    "message": "This file is too large to be exported."
  }
}

有没有办法解决这个错误?

【问题讨论】:

  • 嗯,Google Docs 没有文件限制,因此您的 fileID 是否正确,您是否尝试导出 Google Doc、Sheets 或 Slide?​​span>
  • 是的,对于 5 MB 的问题。

标签: rest google-drive-api


【解决方案1】:

您可以在Files: list 中请求exportLinks 字段,而不是使用此导出端点:

curl \
  'https://www.googleapis.com/drive/v3/files/[FILE_ID]?fields=exportLinks' \
  --header 'Authorization: Bearer [ACCESS_TOKEN]' \
  --header 'Accept: application/json'

这将返回类似这样的内容(这些是我为 Google 幻灯片演示获得的链接):

{
 "exportLinks": {
  "application/vnd.oasis.opendocument.presentation": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=odp",
  "application/pdf": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=pdf",
  "application/vnd.openxmlformats-officedocument.presentationml.presentation": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=pptx",
  "text/plain": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=txt"
 }
}

而且这些 url 没有这么严格的大小限制(我能够输出约 50mb 的 PDF)

【讨论】:

    【解决方案2】:

    如错误消息中所述,API 可以导出的文件大小是有限制的。您确实无法解决必须使用较小文件来解决的问题。

    {
    "error": {
    "errors": [
    {
    "domain": "global",
    "reason": "exportSizeLimitExceeded",
    "message": "This file is too large to be exported."
    }
    ],
    "code": 403,
    "message": "This file is too large to be exported."
    }
    }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-10
    • 2021-05-20
    • 1970-01-01
    • 1970-01-01
    • 2016-01-09
    • 2021-12-20
    • 1970-01-01
    相关资源
    最近更新 更多