python - 无法使用 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 没有问题。
解决方案
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
推荐阅读
- facebook-javascript-sdk - 我收到此错误“找不到变量:FBSDKApplicationDelegate”
- java - 我的 Hibernate CRUD 没有在表中保存数据,但它显示表为空
- python-3.x - 如何计算指定索引以外的元素的总和?
- php - 随机化对象数组的一部分
- php - 将用户从年龄验证重定向到原始网址
- android - Android Workmanger PeriodicWorkRequest API 只能工作一次?
- react-native - 如何自定义 expo 默认启动屏幕并将其隐藏
- php - 如何在 larvel 5.4 中使 JWT 令牌无效或列入黑名单
- javascript - 多次订阅 observable 有时不起作用
- java - Eclipse - 为什么推断 Java 数组的泛型建议