如何使用Google Apps脚本限制文件的复制/下载/打印访问 [英] How to restrict copy/download/print access for a file using Google apps script

查看:46
本文介绍了如何使用Google Apps脚本限制文件的复制/下载/打印访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人找到使用Google Apps脚本限制电子表格的复制/下载/打印访问的方法?背景信息:我创建了一个脚本,该脚本使用setShareableByEditors(false)限制编辑者的共享权限.唯一的问题是,编辑者仍然可以轻松地制作电子表格的副本,然后进行广泛共享.我知道可以在Google表格中手动限制此设置,但是该解决方案无法扩展,因为我正在尝试管理大量电子表格的共享设置.任何建议将不胜感激.谢谢!

解决方案

您可以通过

has anyone found a way to restrict copy/download/print access for a spreadsheet using google apps script? Background info: I created a script which restricts share rights for editors using setShareableByEditors(false). The only problem is that editors can still easily make a copy of the spreadsheet and then share it widely. I know that there's an option to manually restrict this setting in Google Sheets, but this solution is not scalable as I'm trying to manage share settings for a high number of spreadsheets. Any advice would be greatly appreciated. Thank you!

解决方案

You can do this by enabling and using the Advanced Drive Service. You would set the file's restricted label to true. Here's an example:

function restrictFile() {

  var id = '10iM3V2q7FQWBAxy93eN9jvbp_SFco-KLPibeG9XRr71';

  // get the file with the Advanced Drive API (REST V2)
  var file = Drive.Files.get(id);
  Logger.log('File "%s", restricted label was: %s', file.title, file.labels.restricted);

  // set the restricted label
  file.labels.restricted = true;

  //update the file
  Drive.Files.update(file, id);

  // check the updated file
  var updatedFile = Drive.Files.get(id);
  Logger.log('File "%s", restricted label is: %s', updatedFile.title, updatedFile.labels.restricted);

}

You can confirm it also in the UI under File > Share... > Advanced:

这篇关于如何使用Google Apps脚本限制文件的复制/下载/打印访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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