使用Google云端硬盘API更改链接共享权限 [英] Use Google Drive API to change link sharing permissions

查看:404
本文介绍了使用Google云端硬盘API更改链接共享权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过编程方式更改文件的链接共享权限?我正在管理一个Google Apps for Work帐户,并且希望对名为机密"的文件夹中的每个文件都有一个策略,以便对链接共享具有一定的权限集,防止编辑者更改访问权限并添加新用户",和禁用评论者和查看者的下载,打印和复制选项".

Is there a way to programmatically change the link sharing permissions for a file? I'm administering a Google Apps for Work account and I want to have a policy for every file in a folder named "Confidential" to have a certain set of permissions for Link Sharing, "Prevent editors from changing access and adding new people", and "Disable options to download, print, and copy for commenters and viewers".

在Google管理控制台中似乎没有办法做到这一点,但是有没有办法让我编写一个脚本,该脚本会定期执行并修复"每个文件的权限?

It doesn't look like there's a way to do this in the Google Admin console, but is there a way for me to write a script that goes through periodically and "fix" every file's permissions?

推荐答案

首先,Google云端硬盘文件的唯一性在于其在上传时由Google提供的ID,而不是桌面操作系统之类的文件名.

First of all Google Drive File's uniqueness is in their ID which is given by Google when you upload, not in the filename like the desktop OS.

如果您确定只有一个机密"信息,文件,然后您可以列出文件夹中的文件.稍后,您可以修改文件"属性:

If you make sure that there is only one "Confidential" file, then you can list files from folder. Later , you can modify "File" properties by :

  1. 要防止编辑者更改访问权限和添加新人员" :

  1. To "Prevent editors from changing access and adding new people" :

new File().setWritersCanShare(Boolean value)

要禁用评论者和查看者的下载,打印和复制选项":

To "Disable options to download, print, and copy for commenters and viewers":

new Labels().setRestricted(Boolean value)

请注意,标签只能应用于文件,不能应用于文件夹.这是使用Java的,因此您可以安排cron来完成此任务.

Note that label can only be applied to files not folder. This is using Java, so you can can have a cron to accomplish this task.

这篇关于使用Google云端硬盘API更改链接共享权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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