This has come up before, related to the Google Drive SDK: How do I get exportLinks for revisions in Google Drive API.
My problem isn't in getting the exportLinks - just that the ones provided by the API don't work.
Here's a modified version of the "Listing revisions" example from the Advanced Drive Service documentation, that logs the exportLinks
for each revision of a given fileId
.
function listRevisions(fileId) {
var revisions = Drive.Revisions.list(fileId);
if (revisions.items && revisions.items.length > 0) {
for (var i = 0; i < revisions.items.length; i++) {
var revision = revisions.items[i];
var date = new Date(revision.modifiedDate);
Logger.log('Date: %s, PDF exportLink: %s',
date.toLocaleString(),
revision.exportLinks[MimeType.PDF] );
}
} else {
Logger.log('No revisions found.');
}
}
Logs
Here are sample logs for a test document that has two "major" revisions. The revision numbers are provided explicitly in the exportLinks.
[14-11-13 16:40:50:511 EST] Date: November 13, 2014 4:35:55 PM EST,
PDF exportLink: https://docs.google.com/feeds/download/documents/export/Export?id=1V2zkXfyRGh_6gnCXtWlII6sxMQEDcLApRrEk-giIE2s&revision=28&exportFormat=pdf
[14-11-13 16:40:50:512 EST] Date: November 13, 2014 4:37:51 PM EST,
PDF exportLink: https://docs.google.com/feeds/download/documents/export/Export?id=1V2zkXfyRGh_6gnCXtWlII6sxMQEDcLApRrEk-giIE2s&revision=32&exportFormat=pdf
So far, so good. Except that those links open the SAME version of the document... the latest. (Go ahead, try them - the document is public.)
Question: Is there some format of exportLinks that will actually download the specified revisions? (i.e. maybe the 'revision' parameter should be named something else)
Google engineers have reproduced the problem using the code shown below, and have raised an internal bug report regarding this. While the sample code is in Google Apps Script, the problem is in Google Drive itself.
You may track any progress by visiting and starring Issue 4008 on the google-drive-sdk Issue Tracker.