首页 > 解决方案 > 无法使用 PyDrive 上传 .mp4 文件

问题描述

我正在尝试使用以下代码将 .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 没有问题。

标签: pythongoogle-drive-apipydrive

解决方案


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

推荐阅读