本文介绍了在 Google Apps 脚本中将文件的所有权转让给其他用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个小的上传用户界面,我将其包含在 Google 协作平台页面中.它让用户上传文档.由于脚本已发布,它在我的帐户下运行,上传的文件上传到我的谷歌驱动器.我可以从应用程序脚本添加上传文件的人作为编辑器,但我想做的是让他们成为文件的所有者.(从应用程序脚本中,您可以对文件执行 .getOwner() ……但不能执行 .setOwner() ……有人知道解决方法吗?

I have created a little upload UI which I include in a Google Sites page. It let's a user upload a document. Since the script is published it runs under my account and the uploaded file is uploaded to my google drive. I can from apps script add the person that uploaded the file as an editor, but what I would like to do is make them the owner of a file. (from apps script you can do a .getOwner() on a file... but not a .setOwner() ..... does anyone know a workaround?

推荐答案

遗憾的是,Apps 脚本不支持更改文件的所有者.问题 74 是一项功能请求添加此功能,如果您为问题加注星标,您将表明您对该功能的支持并收到更新通知.

Unfortunately changing the owner of a file isn't supported in Apps Script. Issue 74 is a feature request to add this ability, and if you star the issue you'll show your support for the feature and get notified of updates.

------编辑------

------EDITED------

现在有一个方便的方法叫做 setOwner,可以在这里找到:https://developers.google.com/apps-script/reference/drive/file#setOwner(User)

Now there is a handy method called setOwner, which can be found here: https://developers.google.com/apps-script/reference/drive/file#setOwner(User)

还有可能传递新所有者的电子邮件地址而不是 User 对象,这在某些情况下更加方便:https://developers.google.com/apps-script/参考/驱动器/文件#setOwner(String)

There's also the possibility to pass the new owner's email address instead of the User object, which is even more handy in some cases:https://developers.google.com/apps-script/reference/drive/file#setOwner(String)

这篇关于在 Google Apps 脚本中将文件的所有权转让给其他用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 03:00