首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Google Drive API:检查文件夹是否存在

Google Drive API:检查文件夹是否存在
EN

Stack Overflow用户
提问于 2019-06-07 22:33:38
回答 1查看 6.6K关注 0票数 6

我正在使用Google drive API试图回答一个看似简单的问题:驱动器中是否存在某个名称的文件夹?

具体内容:

  • V3
  • Python client驱动程序接口的版本: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参数按文件夹名称查询?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56496333

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档