确保使用正确的身份验证,正确的API密钥和正确的文件ID,例如:
const fileId = 'your-file-id';
const thumbnailRequest = gapi.client.drive.files.get({
fileId: fileId,
fields: 'thumbnailLink',
supportsAllDrives: true,
});
thumbnailRequest.execute((thumbnailResult) => {
if (thumbnailResult && thumbnailResult.thumbnailLink) {
const thumbnailLink = thumbnailResult.thumbnailLink;
// do something with thumbnailLink
} else {
console.log('Thumbnail link not found for file');
}
});
请注意,您需要使用正确的API密钥,并确保文件ID存在且由当前用户具有访问权限。如果文件存储在Google Drive团队驱动器中,请添加supportsAllDrives: true参数。