无法使用PyDrive上传.mp4文件

时间:2020-08-01 22:22:47

标签: python google-drive-api pydrive

我正在尝试使用以下代码将.mp4文件上传到我的云端硬盘。

file = drive.CreateFile({'title': "video", 'mimeType':'video/mp4'})
file.SetContentFile('GOPR1017.mp4')
file.Upload()

我最终收到此错误:

httplib2.RedirectMissingLocation: Redirected but the response is missing a Location: header.

仅在尝试上载.mp4文件时才会发生。该脚本似乎与.jpg无关。

1 个答案:

答案 0 :(得分:0)

file4 = drive.CreateFile({'title':'appdata.json', 
'mimeType':'application/json'})
file4.SetContentString('{"firstname": "John", "lastname": "Smith"}')
file4.Upload() # Upload file.
file4.SetContentString('{"firstname": "Claudio", "lastname": "Afshar"}')
file4.Upload() # Update content of the file.

file5 = drive.CreateFile()
# Read file and set it as a content of this instance.
file5.SetContentFile('cat.png')
file5.Upload() # Upload the file.
print('title: %s, mimeType: %s' % (file5['title'], file5['mimeType']))
# title: cat.png, mimeType: image/png