【发布时间】:2013-10-24 12:44:27
【问题描述】:
我正在尝试使用 Google Drive API 插入文件。打包 Python API 客户端 V3。 当文件很小时它工作正常,但是当文件大小达到 15MB 或更大时开始出现这些错误。
此错误始终显示。
An error occured: <HttpError 400 when requesting https://www.googleapis.com/upload/drive/v2/files?uploadType=resumable&convert=true&alt=json returned "Invalid Upload Request">
代码:
我正在将 MediaInMemoryUpload 与 resumable=True 一起使用,正如对大文件的建议。
file = service.files().insert(body={'title': title, 'description': description,
'mimeType':mime_type,'writersCanShare':False}, convert=True,
media_body=MediaInMemoryUpload(fileData,body["mimeType"], resumable=True)).execute()
fileData 有 32MB 的数据字符串作为电子表格保存在驱动器中。 我尝试了 convert=True 和 False,猜测它无法将大文件转换为电子表格,希望它保存为驱动器中的文件,而不是电子表格。无论如何问题都是一样的。
任何人有任何想法为此找到解决方案吗??
【问题讨论】:
-
您是否按照developers.google.com/api-client-library/python/guide/… 底部的建议尝试捕获异常并重试?
-
你确实用不同的文件大小尝试了很多次。它具有用代码实现的指数回退,因此任何时间的大文件都是相同的问题。
标签: python google-app-engine google-drive-api