Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Google App Engine Python将大文件上载到Google Drive时出现400个错误请求_Python_Google App Engine_File Upload_Google Drive Api - Fatal编程技术网

使用Google App Engine Python将大文件上载到Google Drive时出现400个错误请求

使用Google App Engine Python将大文件上载到Google Drive时出现400个错误请求,python,google-app-engine,file-upload,google-drive-api,Python,Google App Engine,File Upload,Google Drive Api,我正在创建一个谷歌应用程序引擎应用程序,我想在其中上传文件到我的谷歌驱动器文件夹 为此,我正在使用GoogleAPI Python客户端库。 我使用库中的MediaIoBaseUpload函数,因为我从一个表单获取文件内容。我正在使用可恢复上传 当我上传一个15MB左右的小文件时,它可以正常工作,但大于15MB的文件在最后一块中收到错误400错误请求 所有以前的块都可以正常工作,但最后一个块返回错误 我试图上传一个zip文件(大约46MB) 这是我的密码: fh = io.BytesIO(se

我正在创建一个谷歌应用程序引擎应用程序,我想在其中上传文件到我的谷歌驱动器文件夹

为此,我正在使用GoogleAPI Python客户端库。

我使用库中的MediaIoBaseUpload函数,因为我从一个表单获取文件内容。我正在使用可恢复上传

当我上传一个15MB左右的小文件时,它可以正常工作,但大于15MB的文件在最后一块中收到错误400错误请求

所有以前的块都可以正常工作,但最后一个块返回错误

我试图上传一个zip文件(大约46MB)

这是我的密码:

fh = io.BytesIO(self.fileContent)
media = MediaIoBaseUpload(fh, "application/zip", 1024 * 1024, resumable=True)
http = httplib2.Http()
if credentials.invalid is True:
    credentials.refresh(http)
else:
    http = credentials.authorize(http)

drive_service = build('drive', 'v2', http=http)

body = {
    'title': self.fileName,
    'description': "",
    "parents": [{
                    "kind": "drive#fileLink",
                    "id": self.folderId
                }],
    'mimeType': fileMimeType
  }

response = drive_service.files().insert(body=body, media_body=media).execute()

不要为父级设置
kind
属性。请使用以下列表:

"parents": [{ "id": self.folderId }]
父对象的类型是驱动器#父引用,而不是驱动器#文件链接。