我正在使用Java API创建应用程序。但是我无法解决从驱动器下载文件的问题。使用Java API从Google Drive下载文件
我正在尝试使用Google开发者页面上给出的功能。 (下面的链接)
https://developers.google.com/drive/manage-downloads
但是,没有明确提及如何获得/生成downloadURI特定文件。而且我很困惑如何使用downloadURI下载文件。
我使用下面的功能 -
private static InputStream downloadFile(Drive service, File file)
{
if (file.getDownloadUrl() != null && file.getDownloadUrl().length() > 0)
{
try
{
HttpResponse resp = service.getRequestFactory().buildGetRequest
(new GenericUrl(file.getDownloadUrl())).execute();
return resp.getContent();
}
catch (IOException e)
{
e.printStackTrace();
return null;
}
}
else
{
return null;
}
}
在这里,我没能获得哪些文件应该是该函数的输入参数。 请帮我一把。