pydrive: RedirectMissingLocation: Redirected 但响应缺少 Location: 标头

use*_*920 3 google-drive-api pydrive

我需要用新文件覆盖谷歌驱动器文件夹中的现有文件。这就是我所拥有的。

file = drive.CreateFile({'id': <id_of_file_which_I_wish_to_overwrite>})
file.SetContentFile(<my_file_path>)
file.Upload()
print('title: %s, mimeType: %s' % (file5['title'], file5['mimeType']))
Run Code Online (Sandbox Code Playgroud)

我不断从 file.Upload() 行收到错误消息,例如:

RedirectMissingLocation: Redirected but the response is missing a Location: header.
Run Code Online (Sandbox Code Playgroud)

关于是什么原因造成的任何想法?这个位置或标题是什么?我注意到当我在没有 file.SetContentFile 的情况下运行相同的代码时我没有收到这个错误,而是只更改文件元数据而不是覆盖它。

ale*_*e13 5

由于出现错误,您应该查看正在上传到 Google 云端硬盘的文件的大小RedirectMissingLocation

运行上面的代码适用于文件上相同数据的小得多的子集。


blu*_*rfx 5

您知道,PyDrive 是 google-api-python-client 的包装库。

根据这个问题,google-api-python-client 和 httplib2 之间存在一些问题。

所以尝试安装 0.15.0 版本的 httplib2。 pip install httplib2==0.15.0