是否可以通过 Google Drive API 公开共享文件 [英] Is it possible to share a file publicly through Google Drive API

查看:26
本文介绍了是否可以通过 Google Drive API 公开共享文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 Google drive 应用程序,它允许用户创建必须公开的文件.

我可以看到一些示例,我们可以通过 API 在 Google 驱动器中创建文件.

但是,创建文件时,是否可以将文件共享为 public.

解决方案

您可以使用权限提要设置文件的访问控制列表.文档位于此处:

https://developers.google.com/drive/v2/reference/permissionsp>

要公开文件,您需要将角色 reader 分配给类型 anyone

然后,如果您想将链接分享给人们,您可以在 API 中获取文件元数据中返回的 webContentLink URL,它将允许任何用户下载该文件.您还可以使用它将共享文件嵌入到 HTML 中(例如 <img> 标签中的图像).

I am working on Google drive application which will allow user to create file which must be public.

I could see some example where we can create a file in Google drive through APIs.

But, While creating a file, Is it possible to share a file as public.

解决方案

You can set the Access Control List of the file using the Permissions feed. The documentation is located here:

https://developers.google.com/drive/v2/reference/permissions

To make a file public you will need to assign the role reader to the type anyone

Then, if you want a link to share to people, you can grab the webContentLink URL returned in the File metadata in the API, it will allow any users to download the file. You can also use it to embed the shared file into HTML (for instance images in <img> tags) .

这篇关于是否可以通过 Google Drive API 公开共享文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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