我正在尝试构建一个小 python 脚本来编译视频并将其上传到 vimeo。真的大约 9/10 的方式。它正在授权,检查上传配额,获取上传票,通过流上传,检查块大小。所有这些都很好。但是当我尝试调用上传完成时,它会返回
('complete upload response', '{"generated_in":"2.4796","stat":"fail","err":
{"code":"708","expl":"The file could not be saved. Try again.","msg":"File error"}}\n')
这是将视频文件加载到二进制文本中的代码。这是上传时加载到 html 标头中的内容:
def load_video_to_bytes(self, file_name):
with open(file_name, 'rb') as f:
byte = f.read()
return byte
上传调用
def call_upload_file(self, session, ticket_info, file, file_size):
session.headers['Content-Type'] = 'video/mp4'
session.headers['Content-Length'] = file_size
response = session.put(ticket_info['endpoint_secure'], data=file)
return response
其中 session 是一个 rauth 会话,然后是完成上传的调用
def call_upload_complete(self, session, ticket_id, filename):
params = {'method': 'vimeo.videos.upload.complete',
'oauth_token': session.access_token,
'ticket_id': ticket_id,
'filename': filename}
response = self.execute_method(session, params)
return response
这是要点中的所有代码 https://gist.github.com/anonymous/7285498
二进制数据是否加载不正确?
谢谢,