Skip to content Skip to sidebar Skip to footer

Google Drive API Get Thumbnail

I want to get a thumbnail that google drive creates for the stored pdf files. With this function I am listing all the files: listFiles: function (folderId, onData, onError) {

Solution 1:

Ok, the thing is to get the metadata of a file I needed to use a files.get function, not files.list. Another thing is that in the call, field parameter needs to be set. For example:

drive.files.get({
    auth: jwtClient,
    fileId: fileId,
    fields : "thumbnailLink"
})

Solution 2:

You can get essential metadata with following api call. Workaround for python:

self.__results = drive_service.files().list(pageSize=10, supportsAllDrives = True, fields = "files(kind, id, name, mimeType, webViewLink, hasThumbnail, thumbnailLink, createdTime, modifiedTime, owners, permissions, iconLink, imageMediaMetadata)").execute()

or

self.__results = drive_service.files().list(pageSize=10, supportsAllDrives = True, fields = "*").execute()

to get complete metadata.

Reference: https://developers.google.com/drive/api/v3/reference/files#resource


Solution 3:

You can use the fields parameter to change which metadata fields are returned:

drive.files.list({
    auth: jwtClient,
    q: "'" + folderId + "' in parents",
    fields: "files(id, name, mimeType, thumbnailLink)"
}, function (err, res) {
    console.log(res.files)
});

Post a Comment for "Google Drive API Get Thumbnail"