python - Google Drive API - 列出我尚未访问的共享文件夹中的文件

标签 python google-drive-api

我正在尝试自动从 Google Drive 共享文件夹下载文件。文件夹的内容每天都在变化。该文件夹将共享给拥有该文件夹链接的任何人。
我的问题是,除非我在 Google Drive 中打开新文件,否则查询不会返回我尚未打开的新文件。

folder_id = 'xxxx...xxx'
results = drive_service.files().list(q=f"parents in '{folder_id}' and trashed = false", fields="nextPageToken, files(id, name)").execute()
有没有办法列出我尚未打开的共享文件夹中的文件?
我试图否定 sharedWithMe 字段,但它不起作用。

最佳答案

是的,有,但您需要指定要在搜索中包含共享文件夹
这可以通过设置 includeItemsFromAllDrives 来实现和 supportsAllDrivestrue在python中你可以用
folder_id = 'xxx...xxx'
结果 = drive_service.files().list(supportsAllDrives=True, includeItemsFromAllDrives=True, q="parents in '{folder_id}' andtrashed = false", fields = "nextPageToken, files(id, name)").execute( )

更新
请注意 shared with anyone with a link意味着在您打开文件之前,它不会明确与您共享,因此不会显示为文件列表的一部分。如果您想更改此设置,您需要要求所有者将您指定为文件夹的查看者。

关于python - Google Drive API - 列出我尚未访问的共享文件夹中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62414423/

相关文章:

swift - 如何快速获取 iOS 中 Google Drive 中 GTLDriveFile 的修改日期?

python - 过滤列表列的列表,然后在 Python 中逐行拆分(分解)

python - 如何找到运行我的代码的 conda 环境的名称?

python - 在 Mac OS X 中使用 Python 自动授权 Google Drive

google-apps-script - 尝试更改 Google 云端硬盘中文件的所有者

google-app-engine - GAE : java. lang.NoSuchMethodError : com. google.api.client.json.GenericJson.set

python - 将值从 Pandas 中的不同数据帧映射到数据帧

python - 无事发生时显示 fps 为 0

Python 在 chroot 中运行时出现错误

java - 谷歌驱动器 API : Downloading a file in Java