我正在尝试从Google Apps脚本中的数据URI上传并保存图像。除了要设置的文件类型之外,其他所有功能都起作用。我已经按照Apps脚本文档尝试过newBlob的所有变体。function doUpload(dataURI) {var folder = DriveApp.getFolderById("xxxxxxxxxxxxxxxxxxxxxx");var type = (dataURI.split(";")[0]).replace('data:','');var imageUpload = Utilities.base64Decode(dataURI.split(",")[1]);var blob = Utilities.newBlob(imageUpload, type, "nameOfImage");folder.createFile(blob);return true;}
2 回答
MMTTMM
TA贡献1869条经验 获得超4个赞
这是小而重要的修改...
function doUpload(dataURI) {
var folder = DriveApp.getFolderById("xxxxxxxxxxxxxxxxxxxxxx");
var type = (dataURI.split(";")[0]).replace('data:','');
var imageUpload = Utilities.base64Decode(dataURI.split(",")[1]);
var blob = Utilities.newBlob(imageUpload, type, "nameOfImage.png");
folder.createFile(blob);
return true;
}
添加回答
举报
0/150
提交
取消