当Content-Type为text / csv时,Sails.js正文内容

我是否需要做任何特殊的处理POST请求与文本ish Content-Type

我需要处理text/csv但是当我到我的控制器中的方法,它看起来像Sails.js试图parsing正文为JSON:

 postStuff: function(req, res) { sails.log.info("postStuff") sails.log.info(req.body) sails.log.info(req.headers['content-type']); ...etc... 

给我:

 info: postStuff info: {} info: text/csv 

我发现bodyParser中间件的文档有些模糊。

FWIW,我也尝试在请求中将Content-Type设置为text/plain ,但是无济于事。

我也尝试明确添加一个文本bodyParser作为中间件,这似乎没有任何效果:

http.js

 module.exports.http = { bodyParserText: require('body-parser').text(), middleware: { order: [ 'startRequestTimer', 'cookieParser', 'session', 'myRequestLogger', 'bodyParser', 'bodyParserText', 'handleBodyParserError', 'compress', 'methodOverride', 'poweredBy', '$custom', 'router', 'www', 'favicon', '404', '500' ], ...etc... 

哇,这个结果很简单,但是由于缺less来自框架的反馈,所以很难debugging。

https.js ,新中间件的元素必须位于middleware元素内部,如果当然有意义的话:

 module.exports.http = { // NOT HERE // bodyParserText: require('body-parser').text(), middleware: { // HERE bodyParserText: require('body-parser').text(), order: [ 'startRequestTimer', 'cookieParser', 'session', 'myRequestLogger', 'bodyParser', 'bodyParserText', 'handleBodyParserError', ...etc... 

如果sails.js(express?)给出了一个警告,本来是不错的,因为我假设它找不到bodyParserText