Java 将file.getDownloadUrl()设置为null,即使我尝试将作用域设置为DriveScopes.DRIVE\u READONLY和DriveScopes.all()
我同时使用了DriveScopes.DRIVE\u READONLY和DriveScopes.all(),但我仍然得到 file.getDownloadUrl()为空Java 将file.getDownloadUrl()设置为null,即使我尝试将作用域设置为DriveScopes.DRIVE\u READONLY和DriveScopes.all(),java,image-processing,google-drive-api,Java,Image Processing,Google Drive Api,我同时使用了DriveScopes.DRIVE\u READONLY和DriveScopes.all(),但我仍然得到 file.getDownloadUrl()为空 private final static Collection scopes=DriveScopes.all(); InputStream in=null; if(file.getDownloadUrl()!=null&&file.getDownloadUrl().length()>0){ HttpResponse resp=dr
private final static Collection scopes=DriveScopes.all();
InputStream in=null;
if(file.getDownloadUrl()!=null&&file.getDownloadUrl().length()>0){
HttpResponse resp=drive.getRequestFactory().buildGetRequest(新
GenericUrl(file.getDownloadUrl()).execute();
inputStrem=resp.getContent();
}
您使用的API版本是v2还是v3?另外,它是什么类型的文件?我正在使用v2。甚至我也使用了v3。它是一个图像文件OutputStream out=new ByteArrayOutputStream();drive.files().export(file.getId(),“image/jpeg”).executemedia和downloadto(out);和drive.files().get(file.getId()).executeAndDownloadTo(out);它不起作用downloadUrl
仅为非谷歌文档填充。你是用电脑拍到这张照片的吗?您是否已检查资源是否包含任何exportLinks
?您使用的API版本是v2还是v3?另外,它是什么类型的文件?我正在使用v2。甚至我也使用了v3。它是一个图像文件OutputStream out=new ByteArrayOutputStream();drive.files().export(file.getId(),“image/jpeg”).executemedia和downloadto(out);和drive.files().get(file.getId()).executeAndDownloadTo(out);它不起作用downloadUrl
仅为非谷歌文档填充。你是用电脑拍到这张照片的吗?您是否已检查资源是否包含任何导出链接
?
private final static Collection<String> scopes=DriveScopes.all();
InputStream in=null;
if (file.getDownloadUrl() != null && file.getDownloadUrl().length() > 0) {
HttpResponse resp = drive.getRequestFactory().buildGetRequest(new
GenericUrl(file.getDownloadUrl())).execute();
inputStrem = resp.getContent();
}