Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 接收和解释以内容类型作为应用程序/八位字节流发送的十六进制数据时出错_Javascript_Node.js_Character Encoding_Binary_Azure Mobile Services - Fatal编程技术网

Javascript 接收和解释以内容类型作为应用程序/八位字节流发送的十六进制数据时出错

Javascript 接收和解释以内容类型作为应用程序/八位字节流发送的十六进制数据时出错,javascript,node.js,character-encoding,binary,azure-mobile-services,Javascript,Node.js,Character Encoding,Binary,Azure Mobile Services,我正在尝试将二进制数据发送到azure移动服务API。当我们收到请求并尝试解析数据时,高于7f(即80、81、90、ff等)的字节值的解释是不同的。例如,如果我们发送了 Sent data : 67 01 00 00 31 00 31 00 32 00 31 00 00 00 A0 10 Received data: 67 01 00 00 31 00 31 00 32 00 31 00 00 00 ef bf bd 10 这是curl命令: curl --header "Content

我正在尝试将二进制数据发送到azure移动服务API。当我们收到请求并尝试解析数据时,高于7f(即80、81、90、ff等)的字节值的解释是不同的。例如,如果我们发送了

Sent data    : 67 01 00 00 31 00 31 00 32 00 31 00 00 00 A0 10
Received data: 67 01 00 00 31 00 31 00 32 00 31 00 00 00 ef bf bd 10
这是curl命令:

curl --header "Content-Type:application/octet-stream"   -X POST https://x.x.x.x/Api/temp --data-binary @/home/device_data.txt
Nodejs移动服务脚本片段

exports.post = function(request, response) {

    var  payload=new Buffer(request.body);
    console.log(payload);
}

我怀疑我们的8位二进制流被解释为7位字符流。有人能解释一下吗?

request.body来自ExpressJS-请阅读以下内容:

您将注意到request.body不是请求的主体-它是一个已解析的主体。因此,您可能需要显式地使用主体解析器来处理请求

这里是同一事物的另一个例子:

另请查看主体解析器:


不幸的是,我不相信您可以在移动服务案例中设置额外的中间件。您可以做的一件事是将您的应用程序转换到Azure应用程序服务移动应用程序-它采用常规的ExpressJS应用程序,但通过SDK处理身份验证、推送通知和数据访问(请参阅和介绍性博文:)

我认为可以通过git接口在azure移动服务中安装其他软件包。请查收