Google App maker多个文件可驱动上传 [英] Google App maker multiple files drive upload

查看:60
本文介绍了Google App maker多个文件可驱动上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将使用驱动器选择器作为附件字段,因此,每当用户上载一个文件或多个文件来驱动时,我们都必须获取文件的链接,并以表格的形式显示给用户.

We are going to use drive picker as attachement field, so whenever an user uploads a file or multiples files to drive we have to get the links of the files and show it to the user in the form.

推荐答案

以下是具有以下假设的代码示例:

Here is a code sample with following assumptions:

  • 您拥有具有一对多关系的Master和Attachment模型
  • 当前页面的数据源设置为从Master模型记录
  • 数据源处于自动保存模式
// onDocumentSelect Drive Picker's event handler
var create = widget.root.datasource.relations.Attachments.modes.create;

result.docs.forEach(function(doc) {
  create.item.Url = doc.url;
  create.createItem();
});

此代码将向服务器发出N个请求,其中N是附件数.您可以使用 google.script.run 进行单个调用并处理在服务器上创建新的附件记录和关系,但是随后您将需要手动重新加载关系以向用户显示更改.

This code will make N requests to the server, where N is number of attachments. You can use google.script.run to make a single call and handle creating new attachment records and relations on server, but then you'll need manually reload relation to show changes to user.

这篇关于Google App maker多个文件可驱动上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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