DriveApp Google Doc / File icon

69 views
Skip to first unread message

Paul Armstrong

unread,
Aug 13, 2022, 1:13:57 AM8/13/22
to Google Apps Script Community
Hi
Has anyone found a good way to take a file returned by DriveApp and find the icon image associated with it?

var file DriveApp.getFileById(....)
var icon = file. .... get and do what?

The file's mime-type is available, which can act as a key for an image to display. But I'd like to display the same images that Google Drive uses. And ideally, get them from the same source. 

Thanks! 

Paul Armstrong

unread,
Aug 13, 2022, 4:20:42 AM8/13/22
to Google Apps Script Community
Found it.

var json = Drive.Files.get("xxxxx", {supportsAllDrives: true});

json.iconLink is a url to the icon. Which takes the format of https://drive-thirdparty.googleusercontent.com/16/type/<mime-type>

Where <mime-type> is that which is returned by File::.getMimeType()

You're welcome 😉 

Reply all
Reply to author
Forward
0 new messages