使用Google脚本将blob数组附加到Google文档
append an array of blobs to a google doc using google script
我有一个脚本,用户可以提交图片到谷歌文档,但当我上传多个图片与文件输入,谷歌脚本不追加所有的图像。我该如何重写我的代码,使它附加所有我选择的图像与<input type="file" multiple />
给。我上传的所有图片的数组?因为给。theFile[0]不起作用
code.gs:
function doGet() {
return HtmlService.createHtmlOutputFromFile('index');
}
function serverFunc(theForm) {
doc = DocumentApp.openById("my top-secret id...");
var img=doc.appendParagraph(theForm.theFile.getName()+":'n").setIndentStart(4).appendInlineImage(theForm.theFile)
//resize image to fit in page if necessary
while(img.getWidth()>750){
img.setWidth(img.getWidth()/1.1).setHeight(img.getHeight()/1.1)
}
}
index.http:
<form style="outline:2px solid blue;">
<input type="file" name="theFile" multiple />
<input type="button" value="UpLoad" id="button" onclick="google.script.run.serverFunc(this.parentNode)" />
</form>
适用于http://www.fyneworks.com/jquery/multiple-file-upload/#。然后,您可以通过以下方式访问每个文件:
for (i = 0; i < theForm.theFile.length-1; i++) {
var blob = theForm.theFile[i];
var file = folder.createFile(blob);
}
我还建议看看这个例子,但使用DocsList服务代替:https://developers.google.com/apps-script/guides/html/communication形式
相关文章:
- 如何确保通过电子邮件发送的html文档中的Google Drive链接不会被识别为附件
- 使用iFrame嵌入私有Google文档
- 添加<a>元素添加到使用Apps脚本的Google文档中
- $scope在遵循 Google 文档后无法从回调函数访问
- Google 文档如何实现富文本编辑
- 干扰 Google 文档的同源政策
- 方法findText()卡在Google文档的第一段
- 在 Google 文档中创建彩虹文本
- 以编程方式阅读 Google 文档中的评论
- 通过 Google 文档中的脚本修改表格
- 在 Google 文档中检索 ListItem 索引
- Chrome 应用/扩展程序 - 后台请求错误,或允许应用问题加载 Google 文档 API
- 使用应用程序脚本对Google文档中的表格行进行编号
- $.ajax表单使用JSONP提交给Google文档:“;被解释为脚本但用MIME类型text/html传输的资源”;
- Google Apps脚本中Google文档中字符串的文本格式
- 将php表单提交给google文档
- 使用Google脚本将blob数组附加到Google文档
- 将链接从iframe内部的Google文档更改为在iframe外部打开
- 使用Google Drive API和Node.js创建Google文档
- 从成员的google文档生成日程表'可用性