Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 使用GoogleApps脚本从GoogleDrive在google站点上托管图像的替代方案是什么?_Google Apps Script_Google Apps - Fatal编程技术网

Google apps script 使用GoogleApps脚本从GoogleDrive在google站点上托管图像的替代方案是什么?

Google apps script 使用GoogleApps脚本从GoogleDrive在google站点上托管图像的替代方案是什么?,google-apps-script,google-apps,Google Apps Script,Google Apps,以前很简单,只需使用URL{file_Id},但是问题出现了,因为网页托管被Google中断了 你可以在这里查看谷歌的政策 您可以将图像作为免费的google站点资源(例如文件柜或页面附件)托管 或者,您可以将图像托管在谷歌云存储桶中(但这需要启用项目计费),firebase也有类似的服务。简短回答 通过使用以下URL模式,您仍然可以使用Google Drive托管图像: https://drive.google.com/uc?export=view&id={fileId} 解释 我

以前很简单,只需使用URL{file_Id},但是问题出现了,因为网页托管被Google中断了


你可以在这里查看谷歌的政策

您可以将图像作为免费的google站点资源(例如文件柜或页面附件)托管

或者,您可以将图像托管在谷歌云存储桶中(但这需要启用项目计费),firebase也有类似的服务。

简短回答 通过使用以下URL模式,您仍然可以使用Google Drive托管图像:

https://drive.google.com/uc?export=view&id={fileId} 
解释 我认为上面的模式是由几个用户通过检查GoogleDrive预览页面或其他类似页面上的下载按钮“发现”的。网络上有好几篇关于这个“把戏”的帖子,但它没有包含在官方文档中,因此它可以在没有谷歌事先宣布的情况下随时停止

无论如何,这在某些方面可能会起到很好的作用

工具书类

首先,我们需要获取存储在驱动器中的图像的字节形式,要做到这一点,请使用应用程序脚本的实用程序类,并将其编码为base64格式

var base64_Encoded_Image= Utilities.base64Encode(DriveApp.getFileById('<image id in drive>').getBlob().getBytes());
var base64_Encoded_Image=Utilities.base64Encode(DriveApp.getFileById(“”).getBlob().getBytes());
现在将此图像添加到
Firebase拥有免费层的主机:以下是定价链接:
<img alt='NA' src='data:image/png;base64,"+base64_Encoded_Image+"'/>