迭代团队驱动文件Google驱动API JAVA

迭代团队驱动文件Google驱动API JAVA,java,google-drive-api,Java,Google Drive Api,刚开始使用GoogleDrive API进行试验,我可以在我的驱动器中迭代我的文件(已测试,但不在当前代码中,我知道这一点),但我还希望迭代我的团队驱动器文件并打印每个文件的名称和ID 下面是一个代码片段,结果为零,因为我有多个团队驱动器,所以我希望得到一个非零整数值 public static Drive getDriveService() throws IOException { Credential credential = authorize(); return new

刚开始使用GoogleDrive API进行试验,我可以在我的驱动器中迭代我的文件(已测试,但不在当前代码中,我知道这一点),但我还希望迭代我的团队驱动器文件并打印每个文件的名称和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());        
}
也许值得一提的是:我正在使用GoogleDriveAPIv3

当使用意图包含teamDrive时,需要将某些参数设置为true,如include includeTeamDrive项目或语料库。您可以在参考链接中看到这一点,该链接包含一个用于测试的Try-it

你也可以试试