Home Ask Login Register

Developers Planet

Your answer is one click away!

Chaitu Reddy February 2016

Google drive getMimeType returning only null values

I am trying to download files from drive using version 3 of Google Drive api in java. I now need the MimeType of files to identify their content type. when I tried calling


i am getting null value.

 Drive service=getDriveService();

 FileList result = service.files().list()    
           .setFields("nextPageToken, files(id, name)")

 List<File> files = result.getFiles();
     if (files == null || files.size() == 0) {
         System.out.println("No files found.");
     else {
            for (File file : files) {
                System.out.printf("%s (%s)(%s)\n", file.getName(),file.getId(),file.getMimeType());

I tried calling other methods like getFullFileExtension but they all are returning null values.

Could anyone please tell me where i did mistake? And how to solve this get the mimetype and other values.


pinoyyid February 2016

I haven't played much with v3 yet, but from your code you do

setFields("nextPageToken, files(id, name)")

and then


Since you only asked for the id and name to be fetched, it shouldn't be too surprising that mimeType is null. Try adding mimeType to the fields in setFields.

Post Status

Asked in February 2016
Viewed 1,964 times
Voted 8
Answered 1 times


Leave an answer

Quote of the day: live life