状态代码 403 使用 google apps 脚本打开驱动器的映像

问题描述 投票:0回答:1

我正在处理一个图片库,图像的名称和 ID 位于 Google 电子表格中,脚本读取电子表格并动态发布图像。一开始它运行良好,现在我的状态代码为 403。

为了调试问题,我在一个非常简单的测试脚本中硬编码了单个图像

这是“Code.gs”

function doGet(request) {
  var htmlTemplate=HtmlService.createTemplateFromFile("prova");
  return htmlTemplate.evaluate();
}

这是“prova.html”

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title></title>
</head>
<body>
   xxxxxxxxxxxxxxxxxxxxxx
   <img src="https://drive.google.com/uc?export=view&id=11CakSm75WDYnpfd_Qs2LlYoVmJwdAmUR" alt="sample" />
  </div>
</body>
</html>

这是错误的标题:

Stato:              403
Versione:           HTTP/2
Trasferito:         1,39 kB (dim. 0 B)
Referrer Policy:    strict-origin-when-cross-origin
Priorità richiesta: Low
Risoluzione DNS:    Sistema

这是调试脚本的链接

脚本回复代码 403,但直接链接到图像工作正常!

我不明白如何解决这个问题。

感谢您的帮助!

html google-apps-script http-status-code-403
1个回答
0
投票

我终于找到了链接的正确语法。不是我自己的,而是在 Philippe 对这个问题的回复中,他从这个回复中得到了暗示。 诀窍是:

> https://lh3.googleusercontent.com/d/[image id]

而不是

> https://drive.google.com/uc?export=view&id=[image id]

希望能帮到你。

© www.soinside.com 2019 - 2024. All rights reserved.