如何允许查看者通过 Google Drive API 下载文件

How to allow viewers to download a file through Google Drive API

Google 驱动器文件共享中有一个名为 'Viewers and commenters can see the option to download, print, and copy' 的设置。默认情况下为假。我想以编程方式为某些文件启用它,以便观众可以下载它们。我已经有一项服务可以更改 Google 驱动器上文件的权限,但我没有看到任何与此设置相对应的 API:https://developers.google.com/drive/api/v3/manage-sharing

使用 copyRequiresWriterPermission:

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

copyRequiresWriterPermission

调用 Files: update 并在请求正文中指定此 属性 以修改此内容:

{
  "copyRequiresWriterPermission": true
}