通过 Google Drive API 获取共享链接 [英] Get shared link through Google Drive API

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

问题描述

我正在使用 Google 云端硬盘开发一个应用程序.我希望用户能够通过链接共享文件,将权限设置为 anyonewithLink,如 Google 开发者文档.

I am working on an app using Google Drive. I want the user to be able to share files by link, setting the permissions to anyone and withLink as described in the Google Developers documentation.

但是,我不知道要分享哪个链接.当我在 Google Drive 浏览器界面中共享文件时,我看到 Link to share 格式为:

However, I cannot figure out what link to share. When I share a file in the Google Drive browser interface, I see the Link to share in the format:

https://docs.google.com/演示文稿/d/[...]/edit?usp=sharing

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

A link in this format is not part of the file resource object, nor it is returned from the http call setting the permissions. I hope someone can explain to me how to get this link through the REST api?

推荐答案

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

You can use the alternateLink property in the File resource to get a link that can be shared for opening the file in the relevant Google editor or viewer:

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

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

[With API V3](https://developers.google.com/drive/api/v3/reference/files it is suggested to use the webViewLink property.

这篇关于通过 Google Drive API 获取共享链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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