我如何写一个文本文件到谷歌云存储从JavaScript绑定到谷歌表

How do I write a text file to Google Cloud Storage from JavaScript bound to a Google Sheet?

本文关键字:谷歌 存储 JavaScript 绑定 文本 文件 何写一      更新时间:2023-09-26

不久前,我用绑定JavaScript创建了一个Google Sheet,它从Google Sheet内容中组装电子邮件文本,将文本保存为html文件到Google驱动器,然后将html作为电子邮件的正文发送,并链接到标记为"view as html"的html页面

当Google停止允许Google drive托管html页面时,我创建了一个Zapier触发器来将页面复制到DropBox。现在DropBox也不再支持托管html页面。

我从文档中了解到谷歌云存储将托管html页面。我还没有找到一种方法来编写一个文本文件从JavaScript绑定到谷歌表到谷歌云存储。

这是我现在使用的代码片段。我想用将文件写入Google Cloud Storage的代码替换第一个语句,该语句将文本文件写入Google Drive。

  var outFile = DriveApp.getFolderById('0B4Oo7-sRYcsLRlp1V056a21CNEk').createFile(String(String(Number(dtNow))) + ".html", stBdy)  
  stBdy = stBdy.replace('<p align="right">webpage view</p>','<p align="right"><a href="https://dl.dropboxusercontent.com/u/18189100/' + String(Number(dtNow)) +'.html" target="_blank">View As Webpage</a></p>');
  GmailApp.sendEmail(stTo, stSbj, stBdy, {replyTo: stReply, htmlBody: stBdy});

Bruce Mcpherson写了一个有深度的GCS库。你可以在以下网址找到:http://ramblings.mcpher.com/Home/excelquirks/googlecloud/gcsstore