我用 fiddler 创建带标题的帖子消息
content-Type application/text-enriched
app.post('/books',function(req,res){
var writeStream = fs.createWriteStream('C://Books.txt' ,{ flags : 'w' });
writeStream.write(req.body)
我能够在 var writestream 中停止调试,但是当我执行这一行时,我得到了错误 Entity is too large
有什么技巧可以解决这个问题?我只想寄大 文本文件...
在阅读了一些帖子后,我添加了以下内容,但没有帮助...
var bodyParser = require('body-parser');
app.use( bodyParser.json({limit: '2mb'}) );
app.use(bodyParser.urlencoded({
extended: true,
keepExtensions: true,
limit: '2mb',
defer: true
}));
更新
我也尝试过以下
app.use(bodyParser.raw({ type: 'application/text-enriched' }));
app.use( bodyParser.raw({limit: '10mb'}) );
app.use(bodyParser.urlencoded({
extended: true,
keepExtensions: true,
limit: '10mb',
defer: true
}));
也遇到同样的错误...413 Request Entity Too Large
最佳答案
根据body-parser documentation ,您必须根据请求的内容类型对其进行配置。在你的情况下,像
app.use( bodyParser.raw({limit: '1mb'}) );
或者可能是文本
app.use( bodyParser.text({
type : 'application/text-enriched',
limit: '1mb'
}) );
关于javascript - 正文较大 (1.3 mb) 的 Node 发布消息错误 : 413 Request Entity Too Large,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30859574/