How can we list all files from a specific folder on Google Drive

前端 未结 4 1263
灰色年华
灰色年华 2021-01-21 01:48

We noticed that Google Drive API Javascript allows you to list all files from an specific folder, however it brings just basic details from the file. If we want

4条回答
  •  耶瑟儿~
    2021-01-21 02:24

    Don't worry about this problem, its easy. If you want to get all files and folder from specific FOLDER, then just copy and paste this code in your project and it will retrieve all the files and folder from the specific Folder. Note: You should have your own Folder ID

     List result = new ArrayList();
        Files.List request = null;
    
        try {
              request = mService.files().list();//plz replace your FOLDER ID in below linez
              FileList files = request.setQ("'"+MyFoler_Id+"'in parents and trashed=false").execute();
              result.addAll(files.getItems());          
              request.setPageToken(files.getNextPageToken());
            } 
          catch (IOException e)
          {
            System.out.println("An error occurred: " + e);
            request.setPageToken(null);
          }
    

    //Print Out the Files and Folder Title which we have retrieved.

      for(File f:result)
      {
          System.out.println("My recvd data "+f.getTitle());
      }
    

提交回复
热议问题