[英]How to list all files, folders, subfolders and subfiles of a Google drive folder
Any ideas how to query for all the children and the children of the children in a single query? 任何想法如何在一个查询中查询所有孩子和孩子的孩子?
Update 更新
It seems like a simple question. 这似乎是一个简单的问题。 I doubt if there is a simple solution?
我怀疑是否有一个简单的解决方案?
Quering the tree of folders and files can cost a lot of API calls. 查询文件夹和文件树可能会花费大量API调用。 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.
要在列表中查找文件夹及其所有子文件夹(文件夹,文件,子文件夹和子文件),我必须创建一个像索引一样的树。
Conclusion 结论
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.
下一步您必须将结果索引为(递归)查找文件夹的树。
A query option like (ls -R in Unix) would be nice. 像(Linux中的ls -R)这样的查询选项会很好。
I'm trying to do the same in PHP. 我想在PHP中做同样的事情。 My solution is:
我的解决方案是:
rejecting all the elements that not contain the id of my specific folder in its parents id list. 在父父ID列表中拒绝所有不包含我特定文件夹id的元素。
Don't worry, it's just one Google APIs call. 别担心,这只是一个Google API调用。 The rest of the job is local.
剩下的工作是本地的。
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.
将Drive视为平面,调用列出所有内容,并从中生成自己的树。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.