我试图从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