首页 > 解决方案 > 在 Google AppScripts 中,我们如何为共享驱动器中的文件夹添加内容管理器权限?

问题描述

在 AppScripts API 参考中,为文件夹添加权限有两个设置:addEditor(emailAddress) 和 addViewer(emailaddress)。无论如何,我们可以使用 AppScripts 在文件夹上添加“内容管理器”权限吗?

标签: google-apps-scriptgoogle-drive-api

解决方案


Google Drive API 有一个通用方法可以授予组权限,请参阅setSharing(accessType, permissionType)

// Creates a folder that anyone on the Internet can read from and write to. (Domain
// administrators can prohibit this setting for users of a Google Workspace domain.)
var folder = DriveApp.createFolder('Shared Folder');
folder.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.EDIT);

权限包括编辑、查看、组织等...

参考:

类文件夹 | 设置分享

权限

枚举访问


推荐阅读