Google Drive Api - Get Folder Paths

2019-04-07 23:25发布

问题:

I'm currently using the Google Drive API to get a list of folders (or subfolders). In order to do this I use the following URL:

https://www.googleapis.com/drive/v2/files/1234folderid1234/children?key=1234APIKEY1234&q=mimeType='application/vnd.google-apps.folder';

This returns back a list of the folders as expected, however, I also need either the name of the folder or the full folder path. This information is not returned with this call. Is there a way to get the list of folders with the associated folder name or path in one call?

Thanks

回答1:

You need to do two things:

  1. Use files.list (which gives full file resources)
  2. Amend your query to add the parent id you want to search in.

    mimeType = 'application/vnd.google-apps.folder' and 'folderId' in parents