[英]Upload large data to Google drive gives 400 error
我正在尝试使用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 ,猜测它无法将大文件转换为电子表格,希望将其另存为驱动器中的文件,而不是电子表格。 无论如何,问题都是一样的。
有人为此寻找解决方案吗?
虽然不是完整的答案,因为我不知道如何在python中解决此问题,但我相信Google云端硬盘需要分段上传(对于文件大小分成5部分的多次请求),对于大于5MB的上传。 参见https://developers.google.com/drive/manage-uploads#multipart
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.