尝试从 Google Docs 下载文件时,有时会收到 VersionConflictException。我猜这是无害的,但为什么会发生这种情况?
我正在使用 gdata-media-1.0-1.41.3.jar
com.google.gdata.util.VersionConflictException: Conflict
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:612)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)
at com.google.gdata.client.media.MediaService.getMediaResource(MediaService.java:234)
at com.google.gdata.client.media.MediaService.getMedia(MediaService.java:276)
at com.google.gdata.client.media.MediaService.getMedia(MediaService.java:302)
我们使用的代码如下:
DocumentListEntry entry = ... // from the feed of changed documents
MediaContent documentContent = (com.google.gdata.data.MediaContent) entry.getContent();
String uri = documentContent.getUri();
MediaContent downloadContent = new MediaContent();
downloadContent.setUri(uri);
MediaSource mediaSource = docsService.getMedia(downloadContent);
InputStream inputStream = mediaSource.getInputStream();
File file = // some file
OutputStream output = new FileOutputStream(file);
try {
IOUtils.copy(inputStream, output);
} finally {
IOUtils.closeQuietly(output);
IOUtils.closeQuietly(inputStream);
}