如何列出 Google Drive 文件夹的所有文件、文件夹、子文件夹和子文件
问题描述
任何想法如何在单个查询中查询所有孩子和孩子的孩子?
Any ideas how to query for all the children and the children of the children in a single query?
更新
这似乎是一个简单的问题.我怀疑是否有一个简单的解决方案?
It seems like a simple question. I doubt if there is a simple solution?
查询文件夹和文件树可能会花费大量 API 调用.因此,为了解决我的问题,我使用单个查询来列出所有者的所有文件和文件夹.此查询还返回子文件和子文件夹.要在列表中找到文件夹及其所有子文件夹(文件夹、文件、子文件夹和子文件),我必须创建一个类似索引的树.
Quering the tree of folders and files can cost a lot of API calls. So, to solve my problem, I use a single query to list all the files and folders of an owner. This query also returns subfiles and subfolders. To find the folder and all of its children (folder, files, subfolders and subfiles) in the list, I had to create a tree like index.
结论
单个查询是不够的.您必须列出所有或缩小与所有者的查询.接下来您必须索引结果以(递归)找到文件夹的树.
A single query is not enough. You have to list all or narrow the query with an owner. Next You have to index the results to (recursive) find the tree for the folder.
像 (ls -R in Unix) 这样的查询选项会很好.
A query option like (ls -R in Unix) would be nice.
解决方案
我认为您在更新"中的想法是正确的.将 Drive 视为平面,调用列出所有内容,并从中生成您自己的树.
I think you have the right idea in your "update". Treat Drive as flat, make calls to list everything, and generate your own tree from that.
相关文章