【发布时间】:2019-04-30 19:50:14
【问题描述】:
我正在尝试获取我在 Google Drive(Python、Flask)中创建的文件夹列表:
SCOPES = ['https://www.googleapis.com/auth/drive']
drive_credentials = service_account.Credentials.from_service_account_file(
json_url, scopes=SCOPES)
drive_service = build('drive', 'v3', credentials = drive_credentials)
results = drive_service.files().list(
q="mimeType='application/vnd.google-apps.folder'",
spaces='drive').execute()
results.files 是一个空数组。
我不知道出了什么问题。如果我在这里尝试相同的查询https://developers.google.com/drive/api/v3/reference/files/list?apix_params=%7B%22q%22%3A%22mimeType%20%3D%20%27application%2Fvnd.google-apps.folder%27%22%7D 我会看到我所有的文件夹。
另外,如果我删除查询,我可以看到我的所有文件,但看不到文件夹。
UPD。我发现除了入门 pdf 之外,它没有看到任何其他文件。我只创建了几个测试文件,查询仍然只有一个结果。
【问题讨论】:
-
文件列表是用
results.files还是results['files']访问的? -
@OluwafemiSule 它是 resuls.get('files', [])
标签: python flask google-drive-api