0

我正在尝试使用 Wreck 将 mp4 发布到 Hapi 端点,但我收到了Error: Invalid request payload JSON format. 以下是路线。我怀疑我应该指定video/mp4来自 Wreck 的内容类型,但文档没有告诉如何做到这一点,事件测试。请帮我找出那里有什么问题:

{
  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' });
  }
}
4

0 回答 0