我试图在 Android 上的 Google Drive 中下载文件,并且我正在关注https://developers.google.com/drive/manage-downloads#examples中的示例
if (entry.getDownloadUrl() != null && entry.getDownloadUrl().length() > 0)
{
try
{
LogUtils.xi(this, "start opening url:", entry.getDownloadUrl());
/* HttpRequestFactory: Thread-safe light-weight HTTP request factory layer on top of the HTTP */
HttpResponse resp = manager.getDrive().getRequestFactory()
.buildGetRequest(new GenericUrl(entry.getDownloadUrl()))
.execute();
return resp.getContent();
}
catch (IOException e)
{
LogUtils.xe(this, e.toString());
e.printStackTrace();
throw ExceptionUtils.getIOException("Can't open inputstream.", e);
}
}
else
{
LogUtils.xw(this, "The file doesn't have any content stored on Drive.");
return null;
}
但是收到错误 302:有人知道这里发生了什么吗?
03-29 14:56:07.316 E/XXGoogleDrive(25539): [25566][DriveDLFutureTask] [getInputStream]com.google.api.client.http.HttpResponseException: **302 Moved Temporarily**
03-29 14:56:07.326 W/System.err(25539): com.google.api.client.http.HttpResponseException: 302 Moved Temporarily
03-29 14:56:07.326 W/System.err(25539): at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1062)