Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Drive Api - Get Folder Paths

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

like image 570
Nick Avatar asked Dec 04 '12 18:12

Nick


People also ask

How do I find my Google Drive API folder ID?

Getting this folder ID is easy, navigate to https://drive.google.com and make a folder. After you did this, open up the folder and check the URL: Grab this ID and enter it inside the 'Folder ID's' inside the modal to specify that the backup has to be put in that folder.

What is the file path for Google Drive?

The file path is found at the top of the folder or webpage where you are viewing the file. For example: When viewing files in your web browser, the Google Drive file path is at the top of the Google Drive webpage.


1 Answers

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

like image 146
Ali Afshar Avatar answered Oct 09 '22 04:10

Ali Afshar