如何获取公共共享文件/文件夹的链接 [英] How to get the link of a publicly shared file/folder
问题描述
我们可以使用 https://developers.google.com/drive/v2共享文件/文件夹/ reference / permissions / insert 。但是回复( https://developers.google.com/drive/v2/reference/permissions#resource )将不包含共享文件/文件夹的链接。
共享文件/文件夹后,您可以获取链接以共享文件/文件夹使用 https://developers.google.com/drive/v2/reference/files/get 。所以我们需要再发送一个请求来获取链接。如果我们在第一个请求中获得链接,它将很有用。
我刚刚使用Google驱动器的Web界面,并获得了链接模式以共享文件/如下所示:
对于文件:https://docs.google.com/file/d/{file-id } /编辑
对于文件夹:https://docs.google.com/folder/d/{folder-id}/edit
现在工作正常。
获取共享文件/文件夹是否正确?它会在未来破裂吗?
alternateLink 文件资源 from drive.files。*
方法应该包含链接以查看Google云端硬盘中的文件。这是一致的,也是寻找正确URL的最佳方式。
话虽如此,你设计的这些URL可能不会改变,但最好是安全的。
we can share a file/folder using https://developers.google.com/drive/v2/reference/permissions/insert . But the response ( https://developers.google.com/drive/v2/reference/permissions#resource ) won't contain the link to share the file/folder.
After sharing a file/folder, you can get the link to share the file/folder using https://developers.google.com/drive/v2/reference/files/get. So we need to send one more request to get the link. It will be useful if we get the link in the first request itself.
I just played with Google drive web interface and got the pattern of the link to share a file/folder as given below:
For files: https://docs.google.com/file/d/{file-id}/edit
For folders: https://docs.google.com/folder/d/{folder-id}/edit
It is working fine now.
Is it correct to get the shared file/folder? will it break in future?
The alternateLink
of the File resource from drive.files.*
methods should contain the link to view the file in Google Drive. This will be consistent, and the best way of finding the correct URL.
Having said that, likely those URLs that you engineered will not change, but best to be safe.
这篇关于如何获取公共共享文件/文件夹的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!