Hi all,
I've been working with the Drive API and the Javascript client API for several days now, and have made quite some progress. I can list all files on my drive, create new files, delete, copy, etc...
My problem is, I cannot for the life of me figure out how to pull the contents of a file(any file). From reading the docs I've discovered that my returned file resource object is supposed to have a
property named "downloadUrl", and from this I should be able to access the file contents.
None of the file resource objects that are returned to me(via gapi.client.request) have this field/property. Below is the function I am using to get a file.
Can someone please help point me in the right direction? I have to have this demo done by Monday and I've been stuck on this for 2 days....
Client.getFileContent = function getFileContent() {
gapi.client.load('drive', 'v2', function() {
var request = gapi.client.request({
path : '/drive/v2/files/1QmaofXyVqnw6ODXHE5KWlUTcWbA9KkLyb-lBdh_FLUs',
method : 'GET',
params : {
projection: "FULL"
}
});
request.execute(function(response) {
console.log(response);
});
});
};
The returned file resource object has no downloadUrl field/property at all. Also, if I call my functions for performing a file.list operation :
Client.listFiles = function listFiles() {
gapi.client.load('drive', 'v2', function() {
var request = gapi.client.request({
path : '/drive/v2/files',
method : 'GET'
});
request.execute(Client.listCallBack);
});
};
Client.listCallBack = function listCallBack( response ) {
//console.log(response.items);
var files = [];
for( var i=0; i<response.items.length; i++ ) {
files[i] = {
id : response.items[i].id,
title : response.items[i].title,
modDate : response.items[i].modifiedDate,
modUser : response.items[i].lastModifyingUserName,
testField : response.items[i].embedLink
};
}
UI.displayFiles(files);
};
None of the file resource objects returned have this downloadUrl property. This includes files/documents/spreadsheets/etc... that I've created programmatically, and directly through the My Drive UI.
Am I doing something wrong in my function calls? Should I be passing and/or requesting other parameters? Or am I looking for a property other than downloadUrl?
If more information/code is needed please let me know and I will be happy to provide it. Thank you!