刚刚开始尝试Google Drive API,我可以在我的Drive中迭代我的文件(经过测试,但不是在当前代码中,我知道这一点),但我也想迭代我的Team Drive文件,并打印每个文件的名称和ID。
下面是一个代码片段,结果是零,因为我有多个团队驱动器,所以我希望是一个非零的整数值。
public static Drive getDriveService() throws IOException {
Credential credential = authorize();
return new Drive.Builder(
HTTP_TRANSPORT, JSON_FACTORY, credential)
.setApplicationName(APPLICATION_NAME)
.build();
}
public static void main(String[] args) throws IOException {
// Build a new authorized API client service.
Drive service = getDriveService();
Drive.Files.List tmp = service.files().list();
System.out.println(tmp.size());
}也许值得一提的是:我使用的是Google Drive API V3。
发布于 2018-02-23 23:26:19
当使用包含teamDrive的Files.list时,您需要将某些参数设置为true,例如包含includeTeamDriveItems或语料库。你可以在参考链接中读到这一点,其中包括一个用于测试目的的Try-it。
您也可以尝试使用Teamdrives.list。
https://stackoverflow.com/questions/48927449
复制相似问题