【问题标题】:Cannot remove a file from Team Drive with Apps Script无法使用 Apps 脚本从团队云端硬盘中删除文件
【发布时间】:2019-04-04 17:05:15
【问题描述】:

以下代码在 Team Drive 上运行良好:

var files = folder.getFiles();

while (files.hasNext())
{
  var file = files.next();

  file.setTrashed(true);
//Drive.Files.remove(file.getId());
}

注释掉的行在非 Team Drive 文件夹中也可以正常工作。

但是,在团队驱动器上运行 Drive.Files.remove 行会出现此错误:

GoogleJsonResponseException:对 drive.files.delete 的 API 调用失败并出现错误:找不到文件:(此处为文件 ID)

这是权限问题(带有误导性错误)吗?还是我需要做一些特别的事情才能在团队驱动器上运行 Drive.Files.remove?搜索 Stack Overflow 没有任何实际结果。

我检查了文件 ID,它是有效的,脚本以我的身份运行,我是 Team Drive 文件夹的经理。 Drive API 已启用。

谢谢

【问题讨论】:

    标签: google-apps-script google-drive-shared-drive


    【解决方案1】:

    试试这个:

    Drive.Files.remove(fileId, {supportsTeamDrives:true});
    

    不确定这是否会有所帮助,但认为可能值得一试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-28
      • 2020-02-21
      • 2017-09-21
      • 1970-01-01
      • 2018-10-20
      • 2020-01-16
      • 2017-07-13
      相关资源
      最近更新 更多