google-apps-script - Google 应用程序脚本无法由所有者运行脚本
问题描述
我的所有者拥有文档、工作表、幻灯片、表单的附加组件。
我有编辑器
,我尝试以所有者身份运行测试脚本google.script.run
,脚本返回“loadImg 错误(代码:47)”。
如果我尝试将测试脚本作为编辑器运行,则脚本运行良好。
什么是错误代码:47?为什么错误只针对所有者?
客户端代码
window.google.script.run
.withSuccessHandler(() => { resolve({ success: true }) })
.withFailureHandler((err) => {
console.log('error', err);
reject({ reject: true })
})
.loadImg({ data: someData })
应用脚本代码
function loadImg (params) {
let docType = null
if (DocumentApp.getActiveDocument()) docType = 'docs'
if (SpreadsheetApp.getActiveSpreadsheet()) docType = 'sheets'
if (SlidesApp.getActivePresentation()) docType = 'slides'
if (FormApp.getActiveForm()) docType = 'form'
// Create Blob
const imgByte = Utilities.base64Decode(params.img)
const blob = Utilities.newBlob(imgByte, MimeType.PNG, params.name)
// Append a new Image.
if (docType === 'docs') addIconInDoc(blob)
if (docType === 'sheets') addIconInSheets(blob)
if (docType === 'slides') addIconInSlides(blob)
if (docType === 'form') addIconInForm(blob, params.name)
}
解决方案
推荐阅读
- powershell - Azure DevOps Pipeline 脚本中的租户 ID 已审查
- types - 如何在 Rust 中指定值约束?
- c++ - 如果将传递的初始化列表映射为符号 (constexpr),则 MSVC 上的 constexpr std::max 失败
- c# - 如何对解决方案中的所有文件全部 #nullable 禁用
- javascript - 反应卡不显示背景
- google-apps-script - GAS:如何格式化整个工作表中的所有空单元格
- java - 数据库mysql中IP地址与CIDR的比较
- image - 使用 IA 生成的蒙版在图像中抖动模糊区域
- reactjs - JSX 如何区分 props、事件处理程序和自定义 props?
- kubernetes - 使用 Traefik 和 LetsEncrypt 使用 K8/3S 重定向 HTTP