我正在使用Google drive API试图回答一个看似简单的问题:驱动器中是否存在某个名称的文件夹?
具体内容:
googleapiclient
示例:
根据附带的驱动器ID abcdef
,名为June 2019
(和mimeType application/vnd.google-apps.folder
)的文件夹是否存在?
当前路由:
>>> from googleapiclient.discovery import build
>>> # ... build credentials
>>> driveservice = build("drive", "v3", credentials=cred).files()
>>> [i for i in driveservice.list().execute()['files'] if
... i['name'] == 'June 2019' and i['mimeType'] == 'application/vnd.google-apps.folder']
[{'kind': 'drive#file',
'id': '1P1k5c2...........',
'name': 'June 2019',
'mimeType': 'application/vnd.google-apps.folder'}]
所以答案是肯定的,文件夹是存在的。但是应该有一种更有效的方法通过传递driveId
来完成此via .list()
。如何做到这一点?我尝试了各种组合,所有组合似乎都抛出了非200响应。
>>> FOLDER_ID = "abcdef........"
>>> driveservice.list(corpora="drive", driveId=FOLDER_ID).execute()
# 403 response, even when adding the additional requested params
如何使用q
参数按文件夹名称查询?
https://stackoverflow.com/questions/56496333
复制相似问题