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

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

问题描述

我正在研究 Google驱动器应用程序,这将允许用户创建必须公开的文件。

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

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

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

但是,
创建文件时,是否可以共享文件如 public

推荐答案

您可以设置文件使用权限提要。该文档位于以下位置:

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

https://开发人员.google.com / drive / v2 / reference / permissions

要公开一个文件,您需要指定角色 reader 到类型任何人

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

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

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天全站免登陆