Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何从google drive api v3获取文件列表?_Java_Google Drive Api - Fatal编程技术网

Java 如何从google drive api v3获取文件列表?

Java 如何从google drive api v3获取文件列表?,java,google-drive-api,Java,Google Drive Api,我想使用谷歌驱动器API从谷歌驱动器文件夹中获取文件列表 我已经提到这一点 以上内容不适用于V3API。我认为他们已经在版本3中删除了这种支持。 我也提到了这一点 但目前尚不清楚它是如何运作的 我正在使用java sdk。这应该适用于udpdated URI: GET https://www.googleapis.com/drive/v3/files 您可以尝试使用OAuth进行在线演示,在那里您可以找到有关如何使用API和OAuth的更多信息。请查看版本3 v3: 下面是一些示例Java代

我想使用谷歌驱动器API从谷歌驱动器文件夹中获取文件列表

我已经提到这一点

以上内容不适用于V3API。我认为他们已经在版本3中删除了这种支持。 我也提到了这一点 但目前尚不清楚它是如何运作的


我正在使用java sdk。

这应该适用于udpdated URI:

GET https://www.googleapis.com/drive/v3/files

您可以尝试使用OAuth进行在线演示,在那里您可以找到有关如何使用API和OAuth的更多信息。

请查看版本3 v3:

下面是一些示例Java代码DoSearchforPublicClassQuickStart

查看主要方法-您获得一个驱动器,然后可以使用以下方法翻阅文件:

以下是主要方法:


谢谢@chocksaway。在加入setQ方法后,它起作用了。FileList files=service.files.list.setFieldsnextPageToken,fileId,name,parents.setQ'folder_id'在parents.execute中;我需要导入哪个包才能访问getDriveService?非常感谢。
FileList result = service.files().list()
         .setPageSize(10)
         .setFields("nextPageToken, files(id, name)")
         .execute();
public static void main(String[] args) throws IOException {
    // Build a new authorized API client service.
    Drive service = getDriveService();

    // Print the names and IDs for up to 10 files.
    FileList result = service.files().list()
         .setPageSize(10)
         .setFields("nextPageToken, files(id, name)")
         .execute();
    List<File> files = result.getFiles();
    if (files == null || files.size() == 0) {
        System.out.println("No files found.");
    } else {
        System.out.println("Files:");
        for (File file : files) {
            System.out.printf("%s (%s)\n", file.getName(), file.getId());
        }
    }
}