【发布时间】:2021-06-24 17:42:02
【问题描述】:
我正在尝试创建一个 python 脚本,该脚本将使用以下代码删除/回收/删除位于 google 共享驱动器上的文件夹的内容:
Drive = build('drive', 'v3', credentials=creds)
def deleteWorkspace():
principles = Drive.files().list(q="'%s' in parents and not trashed"%(ROOT_FOLDER_ID)).execute().get('files')
if len(principles)>0:
for p in principles:
print(p['name'])
Drive.files().delete(fileId = p['id'],supportsAllDrives=True)
脚本运行完成,没有任何错误,但有问题的文件夹及其内容仍然存在于共享驱动器空间中。
我觉得这特别奇怪,因为我是相关文件夹的所有者,所有与我类似的问题似乎都已通过使用所有者的凭据得到解决。
https://developers.google.com/drive/api/v3/reference/files/delete?hl=en#response
使用上面的链接以及p['id'] 对应的fileId 字符串时,文件夹及其内容已成功从共享驱动器空间中删除。
任何关于为什么我的脚本没有达到使用上述链接时所描述的相同结果的任何建议/建议将不胜感激。
【问题讨论】:
标签: python-3.x oauth-2.0 google-api google-drive-api google-api-python-client