[英]Google Drive API - List files in a shared folder that I have not accessed yet
我正在嘗試自動從 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
和supportsAllDrives
設置為true
來完成
在 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()
更新
請注意, shared with anyone with a link
意味着在您打開文件之前,它不會明確與您共享,因此不會顯示為您的文件列表的一部分。 如果要更改此設置,您需要讓所有者將您指定為文件夾的查看者。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.