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

前端 未结 4 1231
灰色年华
灰色年华 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:11

    I guess you used Children.list(). It only lists id of children which is not the function you want. You should rather use Files.list() with parameter q="'{{FOLDER_ID}}' in parents" and it will list all the files and its details of children of specific folder you want.

    0 讨论(0)
  • 2021-01-21 02:14

    I did much googled for this question but the answer is right here. You have to use following code snippet as i had used:

    Files.List request = mService.files().list().setQ("'Your Folder ID Here' in parents");
    FileList files = request.execute();
    if (files != null) {
      for (File file : files.getItems()) {
        // Meta data
        Log.i("", "Title: " + file.getTitle());
        Log.i("", "Description: " + file.getDescription());
        Log.i("", "MIME type: " + file.getMimeType());
      }
    }
    

    I am sure it will work for you.

    0 讨论(0)
  • 2021-01-21 02:17

    Using googleApis V3 you can do it. This is sample code:

    string FolderId = "1lh-YnjfDFMuPVisoM-5p8rPeKkihtw9";
            // Define parameters of request.
            FilesResource.ListRequest listRequest = DriveService.Files.List();
            listRequest.PageSize = 10;
            listRequest.Q = "'" + FolderId + "' in parents and trashed=false";
            listRequest.Fields = "nextPageToken, files(*)";
    
            // List files.
            IList<Google.Apis.Drive.v3.Data.File> files = listRequest.Execute()
                .Files;
    

    Hope this help.

    0 讨论(0)
  • 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<File> result = new ArrayList<File>();
        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());
      }
    
    0 讨论(0)
提交回复
热议问题