nodejs/express and binary data in POST

前端 未结 2 1381
我寻月下人不归
我寻月下人不归 2020-12-16 03:40

I\'m trying to send binary data to an express app. It works fine, as long as my values are smaller than 0x80. If a single value is 0x80 or greater, it messes up the whole b

2条回答
  •  [愿得一人]
    2020-12-16 04:22

    It turned out to be an encoding issue. Everything seems to default to 'utf8', but in this case it needs to be set to 'binary'.

    For example:

    var buf = new Buffer(body.toString('binary'),'binary');
    

    Equally as important, I needed to set nodejs multiparty parser's encoding to 'binary'. See: https://github.com/superjoe30/node-multiparty/issues/37

提交回复
热议问题