使用Drive API下载文件时出错

问题描述 投票:0回答:1

我正在尝试将Google电子表格ID(文件位于带有每个视图选项的Google云端硬盘中)传递到Google云端硬盘导出API并将文件下载到本地目录。因为我需要将文件下载为xls或xlsx。如果我将mimeType用作“application / vnd.google-apps.spreadsheet”并收到错误消息“不支持请求的转换”。使用Google的API Explorer窗口也会返回相同的错误消息以执行相同的API。如果我将mimeType更改为“text / csv”,那么它的工作正常。请帮我解决我在下面的代码中使用的mimeType错误。

  const drive = google.drive({version: 'v3', auth});
  const res =  drive.files.export({
     fileId: '1YHO6KuXuUdTQmUgPTJkYNiLrkQBWejDREZLEK62ZT_Q',
     mimeType: 'application/vnd.google-apps.spreadsheet',
     responseType: 'stream' });
google-drive-sdk
1个回答
0
投票

将application / vnd.google-apps.spreadsheet替换为application / vnd.openxmlformats-officedocument.spreadsheetml.sheet。像梦一样工作。

© www.soinside.com 2019 - 2024. All rights reserved.