通过 Google Drive API 获取共享链接

2024-04-15

我正在使用 Google Drive 开发一个应用程序。我希望用户能够通过链接共享文件,将权限设置为anyone and withLink如中所述谷歌开发者文档 https://developers.google.com/drive/v2/reference/permissions/insert.

但是,我不知道要分享什么链接。当我在 Google 云端硬盘浏览器界面中共享文件时,我看到Link to share格式为:

https://docs.google.com/presentation/d/[...]/edit?usp=sharing https://docs.google.com/presentation/d/%5B...%5D/edit?usp=sharing

这种格式的链接不是文件资源对象的一部分,也不是从设置权限的 http 调用返回的。我希望有人可以向我解释如何通过 REST api 获取此链接?


您可以使用alternateLink文件资源中的属性来获取可共享的链接,以便在相关的 Google 编辑器或查看器中打开文件:

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

Update

[使用 API V3](https://developers.google.com/drive/api/v3/reference/files https://developers.google.com/drive/api/v3/reference/files建议使用webViewLink财产。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

通过 Google Drive API 获取共享链接 的相关文章

随机推荐