I am using the Java API to create an application. However, I cannot crack the problem of downloading a file from disk.
I am trying to use the function indicated on the Google Developer page. (Link below)
https://developers.google.com/drive/manage-downloads
However, it is unclear how to get / generate downloadURI for a specific file. And also I am confused how to upload a file using downloadURI.
I use the following function -
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;
}
}
Here I cannot get which file should be the input parameter for the function. Please help me.
source
share