【问题标题】:Can't upload .mp4 files using PyDrive无法使用 PyDrive 上传 .mp4 文件
【发布时间】:2020-08-01 22:22:47
【问题描述】:

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

【问题讨论】:

标签: python google-drive-api pydrive


【解决方案1】:
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

【讨论】:

  • 请添加一些散文来解释您的代码和 OP 之间的差异。目的是解释你做了什么,而不仅仅是提供代码
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-07-18
  • 1970-01-01
  • 1970-01-01
  • 2015-04-08
  • 1970-01-01
  • 1970-01-01
  • 2020-03-22
相关资源
最近更新 更多