遍历团队云端硬盘文件Google Drive API JAVA [英] Iterate over Team Drive files Google Drive API JAVA

查看:475
本文介绍了遍历团队云端硬盘文件Google Drive API JAVA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚开始尝试使用Google Drive API时,我可以遍历我的云端硬盘中的文件(经过测试,但不在当前代码中,我知道这一点),但我也想遍历我的团队云端硬盘文件并打印每个的名称和ID。



在下面找到的代码片段中,结果为零,我期望得到一个非零的整数值,因为我有多个Team Drives。

  public static Drive getDriveService()throws IOException {
Credential credential = authorize();
返回新的Drive.Builder(
HTTP_TRANSPORT,JSON_FACTORY,凭证)
.setApplicationName(APPLICATION_NAME)
.build();
}

public static void main(String [] args)抛出IOException {
//构建一个新的授权API客户端服务。
Drive service = getDriveService();
Drive.Files.List tmp = service.files()。list();

System.out.println(tmp.size());
}

或许很好的提及:我正在使用Google Drive API V3。 使用 list#try-itrel =nofollow noreferrer> Files.list ,意图包含teamDrive,您需要将某些参数设置为true,如include includeTeamDriveItems或语料库。您可以在包含Try-it的参考链接中阅读该链接,以便进行测试。您可以尝试 Teamdrives.list


Just started experimenting with the Google Drive API, I can iterate over my files in My Drive(tested but not in the current code, I am aware of that), but I also want iterate over my Team Drive files and print the names and ID's of each.

A code snippet found below, the result is zero, where I expected an non-zero integer value since I have multiple Team Drives.

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());        
}

Maybe nice to mention: I am using the Google Drive API V3.

解决方案

When using Files.list with intent to include teamDrive, there are certain parameters which you need to set to true like include includeTeamDriveItems or the corpora. You can read that in the reference link which includes a Try-it for testing purposes.

You can also try Teamdrives.list.

这篇关于遍历团队云端硬盘文件Google Drive API JAVA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆