I am just trying to implement the Google Drive Picker API in order to download file (on background) submit by a user via Google drive picker.
I did the Google picker and it worked fine but then, I just couldn't download the file. (begin with single file first).
This is my code, in my dream I could download the file right after getting the picker's file.
function createPicker() {
if (pickerApiLoaded && oauthToken) {
var picker = new google.picker.PickerBuilder().
addView(google.picker.ViewId.DOCS).
addView(google.picker.ViewId.PHOTOS).
addView(google.picker.ViewId.FOLDERS).
enableFeature(google.picker.Feature.MULTISELECT_ENABLED).
setOAuthToken(oauthToken).
setDeveloperKey(developerKey).
setCallback(pickerCallback).
build();
picker.setVisible(true);
}
}
// A simple callback implementation.
function pickerCallback(data) {
var url = 'nothing';
if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED) {
var fileId = data.docs[0].id;
var fileUrl = data.docs[0].url;
alert('The user selected: ' + fileId);
console.log(data.docs);
}
var message = 'You picked: ' + url;
document.getElementById('result').innerHTML = message;
}
Note that I would like to download photo and that I have no access to a "downloadUrl" field. Google Drive Picker and Drive API are "On" on my app.
Everything works fine except that I can't download the retrieving file.