We are developing a linking mechanism between our web application and Google Drive. We show Google Picker to our users and the user selects a file and we link selected file to our data in the Picker callback via $.post. Everything works well and we are able to get id,name,mimeType,url and sizeBytes of selected file in the Picker callback.
We also want our users to upload files from Picker and it works as well except one thing. User uploads the file, we get data.docs object successfully in Picker callback but this time "sizeBytes" field is undefined.
Do we miss something or do something wrong? Why is "sizeBytes" field undefined after uploaded in Picker api?
This is how we create Google Picker,
var view = new google.picker.View(google.picker.ViewId.DOCS);
var picker = new google.picker.PickerBuilder()
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.setAppId(appId)
.setOAuthToken(oauthToken)
.addView(view)
.addView(new google.picker.DocsUploadView())
.setLocale(pickerApiLocale)
.setMaxItems(5)
.setCallback(pickerCallback)
.build();
picker.setVisible(true);
Edit:
This is how we fetch callback data;
function pickerCallback(data) {
if (data.action == google.picker.Action.PICKED) {
for (var i = 0; i < data.docs.length; i++) {
var selectedDoc = data.docs[i];
var params = {
fileId: selectedDoc.id,
fileName: selectedDoc.name,
mimeType: selectedDoc.mimeType,
webViewLink: selectedDoc.url,
size: selectedDoc.sizeBytes,
};
$.post('myurl',params,function(){
some code here....
});
}
}
}
If the user uploads a file "sizeBytes" is undefined.