0

我刚开始使用 google drive API for java,我正在使用与网站上描述的相同代码从 google drive 检索文件列表,但该方法execute不存在:(我该怎么办?

  private static List<File> retrieveAllFiles(Drive service) throws IOException {
        List<File> result = new ArrayList<File>();
        Files.List request = service.files().list();

        do {
          try {
            FileList files = request.execute(); //The method execute() is undefined for the type Drive.Files.List

            result.addAll(files.getItems());
            request.setPageToken(files.getNextPageToken());
          } catch (IOException e) {
            System.out.println("An error occurred: " + e);
            request.setPageToken(null);
          }
        } while (request.getPageToken() != null &&
                 request.getPageToken().length() > 0);

        return result;
      }
4

1 回答 1

0

我在路上,所以无法详述。所以,我很快就砍掉了一段我知道有效的代码。

com.google.api.services.drive.Drive _svc;
...
com.google.api.services.drive.Drive.Files.List qry = 
                               _svc.files().list().setQ("trashed = false");
String npTok = null;
do {
  com.google.api.services.drive.model.FileList gLst = qry.execute();
  for (com.google.api.services.drive.model.File gFl : gLst.getItems()) { 
    String id = gFl.getId();
  }
  npTok = gLst.getNextPageToken();
  qry.setPageToken(npTok);
} while (npTok != null && npTok.length() > 0);

祝你好运。

于 2014-08-16T12:12:00.023 回答