What's the right way to find files by “full path” in Google Drive API v2

后端 未结 3 1411
后悔当初
后悔当初 2020-12-15 18:22

dear all

I\'m trying to find a list of documents by \"full path\". And after reading the API reference, it seems to be a complex task. Assume my path is something li

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 19:02

    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:

    1. List files with q = 'root' in parents and title = 'path0' and mimeType = 'application/vnd.google-apps.folder' and pick the first result.
    2. If there is a matching result, get the folder's id and perform another listing with '' in parents and title = 'path1' and mimeType='application/vnd.google-apps.folder' and pick the first result.
    3. Keep going until you reach to your target folder.

提交回复
热议问题