I am trying to get a file thumbnailLink through the Drive Api, in android studio but keep getting errors. The authorization and Drive Service is working just fine and I'm able to get the file name and create files. However when I try to get the file's thumbnail link the error message is
I/error:: getting thumbnail: println needs a message
This is my code right now, the Log to get the file's name works perfectly
public Task<File> getThumbnail(String fileId) {
return Tasks.call(mExecutor, () -> {
Log.i("chegou", "thumbnailLink");
final File file = mDriveService.files().get(fileId).execute();
Log.i("file name", file.getName());
Log.i("file thumbnail", file.getThumbnailLink());
return null;
});
}
Also, I tried to get the thumbnail from the exact same file in the google playground and it worked perfectly
Does anyone has an idea of how to solve it? Thanks!
So, I just dicovered the answer! Apparently there's a permanent link to every thumbnail in drive, you just need the file id
It is: https://drive.google.com/thumbnail?authuser=0&sz=w320&id=[fileid]
EDIT:
Also, I just found out that when you list files if you put in setFields thumbnailLink you can also get a temporary thumbnailLink
Here's an example code:
FileList searchList = mDriveService.files().list()
.setQ("name = '" + fileName + "'")
.setSpaces("drive")
.setFields("files(id, name,size,createdTime,modifiedTime,starred,thumbnailLink,mimeType)")
.execute();
then you just need to get the file from the list to get it's thumbnailLink
searchList.getFiles().get(0).getThumbnailLink()