How to handle ajax/http-post request (responsetype: arraybuffer) using nodejs+express in the backend

前端 未结 2 1359
自闭症患者
自闭症患者 2021-01-25 09:57

Situation : Client js sends ajax request to nodejs express server.

Client

xmlHttpRequest=new XMLHttpRequest();  
xmlHttpRequest.open(\"POST\",\"/some/se         


        
2条回答
  •  借酒劲吻你
    2021-01-25 10:10

    The bodyParser middleware does not parse POSTed binary data. When i tried base64 encoded strings, it would show up as the object name in a JSON object, something like {"data":}, obviously expecting POST-data in the form name=value.

    There might be a middleware that deals with binary data, or you can access the raw data by binding to the "data" event and stack the received chunks into a buffer using the method described in the ProtocolBuffers.js wiki.

    This is using the vanilla http module without express, but should work anyway.

提交回复
热议问题