Reputation: 658
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) {
drive.files.list({
auth: jwtClient,
q: "'" + folderId + "' in parents"
}, function (err, res) {
console.log(res.files)
}
});
The output of a console log for each file looks like this:
{
kind: 'drive#file',
id: '0BapkdhpPsqtgf01YbEJRRlhuaVUf',
name: 'file-name.pdf',
mimeType: 'application/pdf'
}
When I check the google's documentation, it says that metadata of a file should contain all of these properties: https://developers.google.com/drive/v3/reference/files
and there I found: contentHints.thumbnail.image
How do I access it?
Upvotes: 1
Views: 8683
Reputation: 94
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)
});
Upvotes: 8
Reputation: 41
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
Upvotes: 1
Reputation: 658
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"
})
Upvotes: 6