首页 > 解决方案 > 返回与特定用户共享的 Google Drive 文件集合

问题描述

我正在尝试获取用户(让我们使用billyTheUser@gmail.com)是编辑器的文件集合。

我知道这可以通过to:billyTheUser@gmail.com在驱动器搜索栏中搜索几乎立即在谷歌驱动器的前端完成。

我认为这可以在Google App Scripts中完成,但也许我错了。我认为DriveApp.searchFiles会起作用,但我在构建正确的字符串语法时遇到了麻烦。我查看了Google SDK 文档in并猜测我在使用匹配到用户字符串搜索时做错了什么?以下是我采用的方法,但是如果有不同的方法可以按用户完成文件收集,我很乐意改变我的方法。

var files = DriveApp.searchFiles(

   //I would expect this to work, but this doesn't return values
  'writers in "billyTheUser@gmail.com"');

   //Tried these just experimenting. None return values
  'writers in "to:billyTheUser@gmail.com"');
  'writers in "to:billyTheUser@gmail.com"');
  'to:billyTheUser@gmail.com');

   // this is just a test to confirm that some string searches successfully work
   'modifiedDate > "2013-02-28" and title contains "untitled"');

标签: google-apps-scriptgoogle-drive-api

解决方案


尝试将子句中的操作数翻转in为:

var files = DriveApp.searchFiles('"billyTheUser@gmail.com" in writers');

推荐阅读