【问题标题】:Export csv from Google sheet into "Shared Drives" not "My Drives"将 csv 从 Google 工作表导出到“共享驱动器”而不是“我的驱动器”
【发布时间】:2021-05-09 02:56:51
【问题描述】:

我使用了脚本from this post,它在导出到“我的驱动器”中的文件夹时效果很好,但是如果我尝试将它导出到“共享驱动器”中的文件夹中,我会收到以下错误:

GoogleJsonResponseException:对 drive.files.insert 的 API 调用失败并出现错误:找不到文件:1ENj9R......

有没有办法解决这个问题?

【问题讨论】:

    标签: google-apps-script google-sheets google-drive-api


    【解决方案1】:

    根据您的情况,请在查询参数中包含supportsAllDrives。修改this thread中的脚本后,变为如下。

    发件人:

     var resource = {
    title: sheet_Name+".csv",
    mimeType: "application/vnd.csv"
    parents: [{ id: folder_id }]
       }
     var fileJson = Drive.Files.insert(resource,result)
    

    收件人:

    var folderId = "###"; // Please set the folder ID of your shared Drive.
    var resource = {
      title: sheet_Name + ".csv",
      mimeType: MimeType.CSV,
      parents: [{id: folderId}]
    }
    var fileJson = Drive.Files.insert(resource, result, {supportsAllDrives: true});
    

    注意:

    • 在这个修改后的脚本中,它假设您有在共享驱动器中写入文件的权限。请注意这一点。

    参考:

    【讨论】:

      猜你喜欢
      • 2022-11-29
      • 2010-11-30
      • 2016-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-05
      • 2021-08-22
      • 1970-01-01
      相关资源
      最近更新 更多