使用 Vimeo 的 API 完成 PUT 上传时遇到问题。上传进度调用返回:“错误:options.uri 是必需的参数。”
请注意,一切似乎都可以正确上传;在存在错误的情况下,我只是对成功持怀疑态度。
相关代码(Node.js)如下:
app.post('/api/vimeo/complete', function(req, res) {
request({
method: 'PUT',
json: true,
url: req.body.upload_link_secure,
headers: {
'Authorization': 'Bearer OBSCURO-PATRONUM',
'Content-Range': '*/*'
}
}, function(error, response, body){
//console.log('Headers: ' + JSON.stringify(response.headers));
console.log('progress error: ' + error);
fs.writeFile('server_logs/vimeo-progress-log.json', JSON.stringify(response), function(err) {
if (err) {
console.log('log writing error: ' + err);
} else {
console.log('Vimeo progress log written.');
}
});
res.json(body);
});
request({
method: 'DELETE',
json: true,
url: 'https://api.vimeo.com' + req.body.uri,
headers: {
'Authorization': 'Bearer OBSCURO-PATRONUM'
}
}, function(error, response, body){
console.log('complete error: ' + error);
console.log('complete body: ' + body);
res.json(body);
});
});