Skip to content

Commit

Permalink
Replace google content root with api root in download url. Fixes #32.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Mar 25, 2020
1 parent 53df3e4 commit 270ec6a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ dwvjq.google.Drive = function ()
// see https://developers.google.com/api-client-library/...
// ...javascript/reference/referencedocs#gapiclientrequestargs
var request = gapi.client.request({
'path': '/drive/v2/files/' + ids[i],
'path': 'drive/v2/files/' + ids[i],
'method': 'GET'
});

Expand All @@ -250,8 +250,17 @@ dwvjq.google.Drive = function ()
var urls = [];
// ID-response map of each requests response
var respKeys = Object.keys(resp);
var url;
// if the download url uses the google content root,
// replace it with the api root... (see #32)
var contentRoot = "https://content.googleapis.com";
var apiRoot = "https://www.googleapis.com";
for ( var i = 0; i < respKeys.length; ++i ) {
urls[urls.length] = resp[respKeys[i]].result.downloadUrl;
url = resp[respKeys[i]].result.downloadUrl;
if (url.substr(0, contentRoot.length) === contentRoot) {
url = apiRoot + url.substr(contentRoot.length, url.length);
}
urls[urls.length] = url;
}
// call onload
self.onload(urls);
Expand Down

0 comments on commit 270ec6a

Please sign in to comment.