[英]Google Drive API - List files in a shared folder that I have not accessed yet
I am trying to automate the downloading of files from a Google Drive shared folder.我正在尝试自动从 Google Drive 共享文件夹下载文件。 The contents of the folder change daily.
文件夹的内容每天都在变化。 The folder is shared to anyone with a link to the folder.
该文件夹将与任何拥有该文件夹链接的人共享。
My problem is that the query does not return the new files that I have not opened yet unless I open the new files in 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()
Is there a way to list files in a shared folder that I have not opened yet?有没有办法列出我尚未打开的共享文件夹中的文件?
I tried to negate the sharedWithMe field but it does not work.我试图否定 sharedWithMe 字段,但它不起作用。
This you can do by settingincludeItemsFromAllDrives
and supportsAllDrives
to true
这可以通过将
includeItemsFromAllDrives
和supportsAllDrives
设置为true
来完成
In python you can implement it with在 python 中,您可以使用
folder_id = 'xxxx...xxx' results = drive_service.files().list(supportsAllDrives=True, includeItemsFromAllDrives=True, q="parents in '{folder_id}' and trashed = false", fields = "nextPageToken, files(id, name)").execute()
UPDATE更新
Mind that shared with anyone with a link
means that until you open a file, it is not explicitly shared with you and thus won't show up as part of your file list.请注意,
shared with anyone with a link
意味着在您打开文件之前,它不会明确与您共享,因此不会显示为您的文件列表的一部分。 If you want to change this, you need to ask the owner to specify you as a viewer of the folder.如果要更改此设置,您需要让所有者将您指定为文件夹的查看者。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.