简体   繁体   English

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

[英]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 字段,但它不起作用。

Yes, there is, but you need to specify that you want to include shared folders into the search是的,有,但您需要指定要在搜索中包含共享文件夹

This you can do by settingincludeItemsFromAllDrives and supportsAllDrives to true这可以通过将includeItemsFromAllDrivessupportsAllDrives设置为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.

相关问题 Google Drive API 看不到共享文件夹中的文件 - Google Drive API Cannot See Files in Shared Folder 使用 PyDrive 列出共享的 Google Team Drive 文件夹中的所有文件 - List all files in folder in shared Google Team Drive using PyDrive Google 驱动器 api 在浏览器中打开它们之前未能列出文件夹或从与我共享的文件中下载文件,尽管任何人都具有读取权限 - Google drive api failed to list folder or download files from Shared with me before open them in browser once, though anyone have read access 如何列出我使用Google Drive API公开共享的文件? - How do I list files publicly shared by me using google drive API? 谷歌驱动器 API:如何找到我与他人共享的所有文件 - Google drive API : How to find all files I shared with others Google Drive Api客户端:如何获取文件夹中的文件列表 - Google Drive Api Client: How to get the list of files in a folder 使用python的谷歌驱动器文件夹中的文件列表 - List of files in a google drive folder with python Google Drive 在共享云端硬盘中创建新文件夹 - Google Drive create new folder in shared drive 有什么方法可以通过一个请求仅列出 Google Drive API 上根文件夹或根文件夹下任何级别的文件? - Is there any way to list only files that are on root folder or any level under it on Google Drive API with one request? 无法使用 Google Drive 获取共享文件夹中的项目列表 API - Not getting list of items in shared folders with Google Drive API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM