我曾经在执行下面的代码时获取Google生成的Google Docs文件和图像文件的缩略图,但现在我只获得了空值。我甚至尝试在网上公开分享这些文件。
function testThumbnail(){
var theFile = DriveApp.getFileById('PlaceTestFileIDHere');//Use a test file id here
//Show that you have a valid file by logging the name
Logger.log(theFile.getName());
//Get the Thumbnail
var aBlob = theFile.getThumbnail();
//Test the thumbnail result
if(aBlob == null){
Logger.log('no Thumbnail');
}
else{
Logger.log(theFile.getThumbnail().getBytes());
}
}
答案 0 :(得分:2)
function getThumbnailLink(fileId) {
var file = Drive.Files.get(fileId);
return file.thumbnailLink;
}
var selectedDocument = app.createImage(getThumbnailLink(theFile.getId()))
如上所示,使用Drive服务非常有用。