how to resend post multipart/form-data form with upload file to different server with node.js (express.js)?

无人久伴 提交于 2021-02-07 05:10:48

问题


I post a form with file (enctype="multipart/form-data") to node.js (express.js framework) and just want to send this same post request like it is just to different server. what is the best approach in node.js?


回答1:


remove express.bodyParser and try pipes like these:

req.pipe(request('http://host/url/')).pipe(res)



回答2:


You could try it with Mikeal's Request for Node.js (https://github.com/mikeal/request). It would be something like:

app.post('/postproxy', function(req, res, body){
    req.pipe(request.post('http://www.otherserver.com/posthandler',body)).pipe(res);
});


来源:https://stackoverflow.com/questions/9327250/how-to-resend-post-multipart-form-data-form-with-upload-file-to-different-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!