我試圖從Google Drive下載文件。通用文件(pdf,jpg)的下載沒有任何問題。但我無法得到它下載谷歌文件。我得到一個沒有類型和大小爲0的空文件。你知道什麼可能會導致這種情況嗎?使用java從Google Drive下載Google文檔文件
public InputStream download(String id) throws CloudServiceException {
try {
File file = service.files()
.get(id)
.execute();
String link = file.getExportLinks().get("application/pdf");
HttpResponse resp = service.getRequestFactory()
.buildGetRequest(
new GenericUrl(link))
.execute();
return resp.getContent();
} catch (HttpResponseException e) {
throw CloudServiceExceptionTransformer.transform(e, e.getStatusCode());
} catch(IOException ex) {
throw new InternalException(ex);
}
}
那麼如何解決它? – Nakilon