I am trying to search Google Drive for Excel files using the Javascript API (v3). Some Excel files seem to have a mime type of 'application/vnd.ms-excel' and some have a mime type of 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'.
When I use mime type 'application/vnd.ms-excel', the files with that mime type are returned correctly. But, when I use the mime type 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' I get a ton of irrelevant results (with mime types like 'x-javascript', 'x-markdown', and even 'image/png').
Is this a bug or am I doing something wrong?
Any help will be greatly appreciated! Thanks.
Here's my code:
function getItemsByQuery(query, callback) {
var retrievePageOfFiles = function(request, result) {
request.execute(function(resp) {
result = result.concat(resp.files);
var nextPageToken = resp.nextPageToken;
if (nextPageToken) {
request = gapi.client.drive.files.list({ 'pageToken': nextPageToken });
retrievePageOfFiles(request, result);
}
else {
result.length > 0 ? callback(result) : callback([]);
}
});
};
var q = {'q': query };
var initialRequest = gapi.client.drive.files.list(q);
retrievePageOfFiles(initialRequest, []);
}
getItemsByQuery("trashed=false and mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'", function(results) {
// Handle results - lots of irrelevant files returned here.
});