首页 > 解决方案 > 如何允许查看者通过 Google Drive API 下载文件

问题描述

Google 云端硬盘文件共享中有一项设置,称为“查看者和评论者可以看到下载、打印和复制的选项”。默认为假。我想以编程方式为某些文件启用它,以便观众可以下载它们。我已经有一项服务可以更改 Google Drive 上文件的权限,但我没有看到任何与此设置对应的 API:https ://developers.google.com/drive/api/v3/manage-sharing

标签: google-drive-api

解决方案


使用 copyRequiresWriterPermission:

该选项Viewers and commenters can see the option to download, print, and copy在 API 中对应于File中的以下字段:

copyRequiresWriterPermission

调用文件:更新并在请求正文中指定此属性以修改此属性:

{
  "copyRequiresWriterPermission": true
}

推荐阅读