Question

Apologies if this question already exists, i have searched for two days now. I am trying to list all files from google drive root folder which have not been trashed using javascript, this is the code am using

function retrieveAllFilesInFolder(folderId, callback) {
     gapi.client.load('drive', 'v2', function() {
     var retrievePageOfChildren = function(request, result) {
     request.execute(function(resp) {
       result = result.concat(resp.items);
       var nextPageToken = resp.nextPageToken;
       if (nextPageToken) {
         request = gapi.client.drive.children.list({
          'folderId' : folderId,
          'pageToken': nextPageToken,
          'q' : 'trashed = false '
       });
      retrievePageOfChildren(request, result);
  } else {
     callback(result);
  }
});
}
 var initialRequest = gapi.client.drive.children.list({
  'folderId' : folderId
  });
retrievePageOfChildren(initialRequest, []);
});
}

but the result contains both trashed and files that have not been trashed, so i don't really know what's wrong

Was it helpful?

Solution

I had a similar problem, solved by putting the q parameter into the initial request as well:

var initialRequest = gapi.client.drive.children.list({  
'folderId' : folderId, 
'q' : 'trashed = false'
 });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top