EDIT: Everything except pdf seems to give the correct revision. Only if I request a pdf, do I get the latest revision regardless of the revision id i passed
This should be simple, but I'm always getting the head revision instead of the previous versions when I try to download.
Here's a snippet of my code
RevisionList revList = service.revisions().list(fileId)
.setMaxResults(10)
.execute();
// Got all revisions here
List<Revision> revisions = revList.getItems();
if (revisions == null || revisions.size() == 0) {
System.out.println("No revisions found.");
} else {
// Got the first revision I made to the file
Revision rev = revisions.get(0);
// Date is in 2015 for this particular revision
String date = rev.getModifiedDate().toString();
String filePath = System.getProperty("user.dir") + "/" +
date.substring(0, date.indexOf('T'))+".pdf";
OutputStream out = new FileOutputStream(filePath);
MediaHttpDownloader downloader =
new MediaHttpDownloader(HTTP_TRANSPORT, service.getRequestFactory().getInitializer());
downloader.setProgressListener(new MediaHttpDownloaderProgressListener() {
public void progressChanged(MediaHttpDownloader downloader) {
switch (downloader.getDownloadState()) {
case MEDIA_IN_PROGRESS:
System.out.println(downloader.getProgress());
break;
case MEDIA_COMPLETE:
System.out.println("Download is complete!");
}
}
});
downloader.download(new GenericUrl(rev.getExportLinks().get("application/pdf")), out);
}