google-api - 来自 html 的谷歌文档 - 不一致地包括图像
问题描述
我有一个简单的脚本,它使用 NPM 的 googleapis 库将相对较短的 HTML 字符串转换为 google 文档。这有少量的文本和几个<img>
标签。我遇到的问题是,有时 1 个图像在最终文档中,有时是不同的图像,有时是三个图像中的 2 个,很少是全部 3 个或没有。
我觉得我错过了等待异步的步骤,但我无法弄清楚它可能是什么。这是我的代码:
const drive = google.drive({ version: 'v2', auth });
drive.files.insert({
media: {
mimeType: 'text/html',
body: html // html is a simple string of html with some <img> tags
},
convert: true
})
.then(res => {
// here I export the file as a PDF and do stuff with that
});
解决方案
推荐阅读
- c# - 如何检测1台计算机中何时有2个用户/帐户并检测当前正在使用的用户/帐户
- javascript - 如何显示服务器
- c++ - 打开文本文件的前 10 行,然后根据需要打开更多行
- sql - SQL Server 循环模拟订单容量(无限循环问题)
- r - 如何在 R 中创建构造函数?
- javascript - JS中添加一行时PHP和JS之间的通信
- visual-studio-code - 打开文件夹/工作区后关闭 VS Code 欢迎屏幕
- c# - 如何跨多个子列表获取同一索引处的值?
- package - 在 SAGE 8.9 中安装 GAP 包
- swift - 无法在 Swift Playground 中导入 tensorflow