[英]Get shareable link of Google Drive files in a specific folder
I've been trying to apply the solution described here , adapting from the PyDrive documentation .我一直在尝试应用这里描述的解决方案,改编自PyDrive 文档。 What I want is to work on files in a specific folder, not get a list of all files in my Drive (which contains thousands).我想要的是处理特定文件夹中的文件,而不是获取我的云端硬盘中所有文件的列表(包含数千个文件)。 So I've tried:所以我试过:
files = drive.ListFile({'q': "'myfolder' in parents"}).GetList()
where myfolder
is the name of the folder I want to get this list from.其中myfolder
是我要从中获取此列表的文件夹的名称。 However, this returns an HTTP 404 error.但是,这会返回 HTTP 404 错误。 Replacing myfolder
with root
works (per Google's example ), but take ages (so my syntax is correct, but I probably misunderstand what parents
represents).用root
替换myfolder
可以工作(根据谷歌的例子),但需要很长时间(所以我的语法是正确的,但我可能误解了parents
代表的意思)。
Can anyone help?任何人都可以帮忙吗?
I actually was nearly there: I needed to pass the folder ID instead of the name in the query:实际上我就快到了:我需要在查询中传递文件夹 ID 而不是名称:
files = drive.ListFile({'q': "'folder_id' in parents"}).GetList()
From there, I get a collection of dictionaries from which it's easy to get the file name ( title
key) and shareable link ( alternateLink
).从那里,我得到了一个字典集合,从中可以很容易地获取文件名( title
键)和可共享链接( alternateLink
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.