What's the right way to find files by "full path" in Google Drive API v2
Unlike conventional file systems, a file could be under multiple folders on Drive. Folders are pretty much similar what labels are. Therefore, conventional paths dont always work within our abstraction. I'd suggest you to follow the logic below:
- List files with q =
'root' in parents and title = 'path0' and mimeType = 'application/vnd.google-apps.folder'
and pick the first result. - If there is a matching result, get the folder's id and perform another listing with
'<id of path0>' in parents and title = 'path1' and mimeType='application/vnd.google-apps.folder'
and pick the first result. - Keep going until you reach to your target folder.
The biggest problem is that a path does not uniquely identify the file or folder! For example, in the web UI, you can make 2 folders with the same name as children of the same folder.
i.e. you can make a tree that looks like:
root
|-somefolder
|-somefolder