使用Google Apps脚本从Google云端硬盘在谷歌网站上托管图片的替代品是什么? [英] What is the substitute for hosting images in google site from Google Drive using Google Apps Script?

查看:97
本文介绍了使用Google Apps脚本从Google云端硬盘在谷歌网站上托管图片的替代品是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前这很简单,只需使用URL https://googledrive.com/host/ { file_Id}但是,问题出现是因为Google停止了网页托管?

It was very simple before, simply using the URL https://googledrive.com/host/{file_Id} but, the problem arises because the web page hosting is being discontinued by Google?

您可以在链接

You can check the Google Policy in the link here.

推荐答案

首先,我们需要获取存储在驱动器中的字节形式的图像,使用Utilities类应用程序脚本并以base64格式编码

First, we need to get the byte form of image stored in the drive, to do that use Utilities class of app script and encode that in base64 format

var base64_Encoded_Image= Utilities.base64Encode(DriveApp.getFileById('<image id in drive>').getBlob().getBytes());

现在将此图片添加到< img> tag使用这个

now to add this image in <img> tag use this

<img alt='NA' src='data:image/png;base64,"+base64_Encoded_Image+"'/>

这篇关于使用Google Apps脚本从Google云端硬盘在谷歌网站上托管图片的替代品是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆