Is it possible to read the contents of a Google Apps Script from another Script

為{幸葍}努か 提交于 2019-12-22 08:02:09

问题


I'm looking for a way to read the contents of the script.gs files within a standalone Google Apps Script. I can't find a suitable getAs() Mime format in the Docslist.File service that doesn't fail. The context of this is that I want to use the html service/content service to be able to embed public GAS source samples in Google Sites and elsewhere. (in much the same way as embedding Gist Samples). Any ideas?


回答1:


It is, in fact, possible. This gets Code.gs:

function myFunction() {
  throw ScriptApp.getResource("Code").getDataAsString();
}



回答2:


There is no way to programmatically retrieve the contents of a ".gs" file. You can only ask for files with ".html" extension and potentially you can return it in a project.

This request has come up in the context of allow local development or Git integration to provide an API way to get/set script source in a file. Please put your comments in this issue tracker request or log a new one if it makes sense .

http://code.google.com/p/google-apps-script-issues/issues/detail?id=1108



来源:https://stackoverflow.com/questions/13210469/is-it-possible-to-read-the-contents-of-a-google-apps-script-from-another-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!