【发布时间】:2021-06-03 11:17:23
【问题描述】:
目前,我正在从 HTML 表单中上传图像文件,并使用以下代码将其转换为 base64:
fileImput.addEventListener("change", function() {
if (file = this.files[0]) {
let reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function() {
var base64String = reader.result;
}
}
我将 base64String 传递给服务器并将其保存在文档的属性中。
到那里为止,一切都很完美。问题是我需要将该图像文件包含在电子邮件中,使用 blob 格式包含图像,并在 HTML 表单中包含使用 base64 格式的图像。为了更复杂,我从 Drive 中获取了一些图像文件并获取文件的 blob:
driveFile.getBlob();
我找不到任何方法在应用脚本中将 base64 转换为 blob,反之亦然。
另外,我希望完全了解 blob 格式。如果您可以参考我一些好的文档,我将非常感激。
【问题讨论】:
标签: google-apps-script base64 blob