【问题标题】:How to read files in multiple folders under Shared Google Drive? [duplicate]如何读取共享 Google Drive 下多个文件夹中的文件? [复制]
【发布时间】:2019-08-20 15:27:03
【问题描述】:

是否可以在 Google 共享驱动器中获取文件? PyDrive 能够遍历 MyDrive 中的文件,但不能遍历 Shared Drive。这些文件位于多个文件夹中:

Department -> PDF -> MONTH YEAR -> DATE -> DAILY REPORT.pdf

代码尝试但都返回“查看文件夹级别”:

# #Make GoogleDrive instance with Authenticated GoogleAuth instance
# drive = GoogleDrive(gauth)
f = drive.ListFile({"q": "mimeType='application/vnd.google-apps.folder' and trashed=false}).GetList()

for folder in f:
    print(folder['title'], folder['id'])

查看文件级别:

# # Auto-iterate through all files that matches this query
# file_list = drive.ListFile({'q': "'{}' in parents and trashed=false".format(folder_id)}).GetList()
# # print(file_list)
# for file1 in file_list:
#   print('title: %s, id: %s' % (file1['title'], file1['id']))

【问题讨论】:

    标签: python python-3.x google-api google-drive-api pydrive


    【解决方案1】:

    发现了一个类似的案例。 它现在可以使用代码:

    # file_list =  drive.ListFile({'q':"'<Team_Drive_Id_Or_Folder_Id>' in parents and trashed=false", 'corpora': 'teamDrive', 'teamDriveId': '<Team_Drive_Id>', 'includeTeamDriveItems': True, 'supportsTeamDrives': True}).GetList()
    

    How can I access a Team Drive instead of personal Google Drive using PyDrive?

    【讨论】:

      猜你喜欢
      • 2016-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-29
      相关资源
      最近更新 更多