nodejs:解析多部分/混合 [英] nodejs : Parsing multipart/mixed
问题描述
我想通过 nodejs 解析Multipart/mlixed"内容,我尝试使用以下代码但 req.body 始终为空:
I want through nodejs to parse a "Multipart/mlixed" content, I tried using the following code but the req.body is always null:
var express = require('express');
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: true }));
var app = express();
app.post('/documents/videoCollect', function(req, res, nexr){
console.log(req.body);
res.send(req.body);
});
下面是多部分/混合内容的示例:
below an example of a multipart/mixed content:
'content-type': 'multipart/mixed; boundary="----=_XXXXXXX"'
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<test>
<name>testName</name>
</test>
你知道是否有一个解析器模块,或者我怎么做?我尝试使用 body-parser、body-parser-xml 和强大的,并且 req.body 始终为空.
Do you know if there is a parser module for this, or how I could do it? I tried with body-parser,body-parser-xml and formidable and the req.body is always null.
推荐答案
body-parser 不处理多部分主体,因为它们复杂且通常很大.对于多部分主体,您可能对以下模块感兴趣:
body-parser does not handle multipart bodies, due to their complex and typically large nature. For multipart bodies, you may be interested in the following modules:
- busboy 和 connect-busboy
- 多方和多方连接
- 强大
- 多路
该模块提供以下解析器:
This module provides the following parsers:
- JSON 正文解析器
- 原始正文解析器
- 文本正文解析器
- URL 编码的表单正文解析器
这篇关于nodejs:解析多部分/混合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!