如何通过 google drive api v3 in java 直接下载文件 link

How to get the direct download link of a file by google drive api v3 in java

如何通过 google 驱动器 api v3 在 java 中直接下载 link 文件?

大家好, 我在 Android 中使用 Google Drive Api 一周,我同时使用 Android Drive SDK 和 Drive Rest Api for java但我找不到如何在云端硬盘上直接下载 link 文件(任何人都可以阅读)的方法。 我试过 How to get the url of a file of google drive to download in android 但没用。 请帮我。 谢谢。

如果您想直接下载 link 文件,DriveFile 似乎不是您想要的。您可以做的是改用 Drive API 网络服务。请注意,您仍然需要通过身份验证才能使用 API.

查看文档的 Download Files 部分,您可以通过 3 种方式下载文件。

另一种选择是使用 webContentLink 供您下载文件。但是,这仅适用于 Drive 中包含二进制内容的文件。

鉴于您拥有该文件的实际 FILE-ID,您可以使用下载 link

下载它

drive.google.com/uc?id=FILE-ID&export=下载