【发布时间】:2019-02-26 17:26:37
【问题描述】:
我正在根据我们的 Google Team Drive 文件的内容实现基于树的查看器;为了做到这一点,我遵循这里给出的建议:How do I search sub-folders and sub-sub-folders in Google Drive?,即执行 2 个 API 调用 - 一个获取所有文件夹,另一个获取所有这些文件夹的直接子文件。
但是,我注意到获取所有文件夹的调用并没有返回所有文件夹:
res = service.files().list(
corpora='teamDrive',
pageSize=1000,
supportsTeamDrives=True,
includeTeamDriveItems=True,
teamDriveId=TEAM_DRIVE_ID,
fields='files(id,parents,name,mimeType)',
q="mimeType='application/vnd.google-apps.folder' and trashed=false"
).execute()
len(res['files'])
# 460
在这里,文件不应该超过pageSize,但我肯定会从这个结果中丢失大量文件夹,例如一个 ID 为 specified_id 的特定的:
len([x for x in res['files'] if x['id'] == specified_id])
# 0
我不认为这是权限问题,因为我可以正常获取此文件:
specific_file = service.files().get(
fileId=specified_id,
supportsTeamDrives=True,
).execute()
specific_file
{'id': '...',
'kind': 'drive#file',
'mimeType': 'application/vnd.google-apps.folder',
'name': '...',
'teamDriveId': '...'}
任何其他关于尝试以实现在一个 API 请求中获取 Google(团队)驱动器中的所有文件夹的目标的其他提示将不胜感激。
【问题讨论】:
标签: python google-drive-api google-drive-shared-drive