简体   繁体   中英

Setting search parameters for javascript google drive api

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

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'
 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM