我正在尝试使用Wreck将mp4发布到Hapi终点,但我收到Error: Invalid request payload JSON format
。以下是路线。我怀疑我应该从Wreck指定一个内容类型video/mp4
,但是文档没有说明如何做到这一点,事件测试。请帮我找出那里的错误:
{
method: 'POST',
path: '/upload/mov',
handler: function (request, reply) {
const source = path.join(__dirname, '../data/mov.mp4');
const stats = fs.statSync(source);
const fileStream = fs.createReadStream(source);
const req = Wreck.request('post', '/api/upload/mov', {
baseUrl: baseUrl,
payload: fileStream,
maxBytes: 7073741824 // 70mb
});
req.on('response', (res) => {
// code removed to try to isolate the problem
reply({ message: 'finished' });
});
}
},
{
method: 'POST',
path: '/api/uplaod/mov',
config: {
payload: {
maxBytes: 7073741824 // 70mb
}
},
handler: function (request, reply) {
// const stream = request.pipe(request.response);
// code removed to try to isolate the problem
reply({ message: 'sent' });
}
}