简体   繁体   中英

Google Drive API Requests in JavaScript?

I am trying to list all the folders in my Google Drive, via the Google Drive API.

I copied the code from the API guide as follows:

var request = gapi.client.drive.files.list({
     'pageSize': 10,
     'fields': "nextPageToken, files(id, name)",

 });

This code returns ALL the files in my directory. How would I change the code to only include folders?

Thanks

It would be done like so in JavaScript:

var request = gapi.client.drive.files.list({
     'pageSize': 100,
     'fields': "nextPageToken, files(id, name)",
     'q':"mimeType='application/vnd.google-apps.folder'"

});

Where, the additional line is 'q':"mimeType='application/vnd.google-apps.folder'"

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