通过DriveApp.getFileById将图像从Google云端硬盘映射到Google幻灯片 [英] Image from Google Drive to Google Slides via DriveApp.getFileById

查看:101
本文介绍了通过DriveApp.getFileById将图像从Google云端硬盘映射到Google幻灯片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在但是对于我尝试过的每种图像格式,Google Apps脚本中都会显示一条错误消息:

But for every image-format I tried, there is an error message in Google Apps Script:

无效的请求[0] .createImage:提供的图像位于 不支持的格式.

Invalid requests[0].createImage: The provided image is in an unsupported format.

Drive-and Slides API已在Google Advanced Services中激活.该文件夹和文件具有公共共享.

Drive- and Slides API is activated in Google Advanced Services. The folder and the file has a public share.

有人成功使用DriveApp.getFileById()命令随后成功导出到Google幻灯片吗?

Does anyone use the command DriveApp.getFileById() with subsequent export to Google Slides successfully?

推荐答案

接下来的修改如何?

var imageUrl = DriveApp.getFileById('0B6cQESmLJfX...').getUrl();

收件人:

var imageUrl = DriveApp.getFileById('0B6cQESmLJfX...').getDownloadUrl() + "&access_token=" + ScriptApp.getOAuthToken();

从该文档看来,访问令牌是必需的. https://developers.google.com/slides/how-tos/add-图片

From this document, it seemed that the access token is required. https://developers.google.com/slides/how-tos/add-image

从2020年1月开始,访问令牌不能与access_token=###之类的查询参数一起使用.

From January, 2020, the access token cannot be used with the query parameter like access_token=###. Ref So please use the access token to the request header instead of the query parameter.

对于OP,我认为可以使用此答案.

In OP's case, I think that this answer can be used.

这篇关于通过DriveApp.getFileById将图像从Google云端硬盘映射到Google幻灯片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆