我想使用 Google Drive api 从 Google Drive 文件夹中获取文件列表。
我已经提到过这个 stack overflow question
以上不适用于 v3 api。我认为他们已经在版本 3 中删除了该支持。 我还提到了这个doc 但尚不清楚它是如何工作的。
我正在使用java sdk。
最佳答案
看看版本 3 (v3):
https://developers.google.com/drive/v3/web/quickstart/java
有一些 Java 代码示例(请搜索“public class Quickstart”)。
查看主要方法 - 您获得一个云端硬盘,然后可以使用以下方法“浏览”文件:
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());
}
}
}
关于java - 如何从 google Drive api v3 获取文件列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44655239/