Node.js错误:上传批量数据时参数太多错误 [英] Node.js error: too many parameters Error while uploading bulk data

查看:224
本文介绍了Node.js错误:上传批量数据时参数太多错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一项任务是通过csv文件批量上传用户数据。我正在使用 nodejs express 框架。当我提交具有60到70行的csv文件时,它工作正常,但是当它超过70行时,它开始给服务器错误太多参数。经过一些研究后我得出结论,它可能是身体解析器大小的问题,所以我尝试了这个博客,但它没有工作错误仍然是相同的。

I have a task to upload user data in bulk through csv file. I am using nodejs and express framework. When i submit csv file having 60 to 70 rows it works fine, but when it exceeds 70 rows it starts giving server error too many parameters. After some research i concluded that it may be the problem of body parser size, so i tried This blog , but it didnt worked error is still same.

这是我的身体解析器代码:

here is my code for body parser:

var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
app.use(cookieParser());
app.use(bodyParser({limit: '50mb'}));
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({ extended: false }));

错误讯息:

2016-04-19T10:29:45.299Z - error: [req#d3a1fa1a-278e-496e-9cb1-b3a944e3d1c8/app] [App] Error: too many parameters Error: too many parameters
    at queryparse (d:\Git\gap-vm 13416\node_modules\body-parser\lib\types\urlencoded.js:119:17)
    at parse (d:\Git\gap-vm 13416\node_modules\body-parser\lib\types\urlencoded.js:64:9)
    at d:\Git\gap-vm 13416\node_modules\body-parser\lib\read.js:91:18
    at IncomingMessage.onEnd (d:\Git\gap-vm 13416\node_modules\raw-body\index.js:136:7)
    at IncomingMessage.g (events.js:273:16)
    at emitNone (events.js:80:13)
    at IncomingMessage.emit (events.js:179:7)
    at endReadableNT (_stream_readable.js:906:12)
    at nextTickCallbackWith2Args (node.js:474:9)
    at process._tickCallback (node.js:388:17)

所以,谁能告诉我哪里出错了。任何建议都会有所帮助。 Thanx提前。

So , can anyone tell me where i am going wrong. Any suggestion would be helpful. Thanx in advance.

推荐答案

正如其他人所说,你需要设置 parameterLimit 处理参数太多错误。您可能还需要将 limit 设置为更大的大小,以避免加载大小错误。对于CSV,将应用urlencoded限制,但其他人也可能也想要设置JSON限制。除非代码中有其他位置覆盖这些设置,否则以下设置将起作用:

As others mention, you'll need to set the parameterLimit to deal with the "too many parameters" error. You may also need to set the limit to a larger size to avoid a load size error. In the case of CSV, the urlencoded limits will be applied, but others may also want to set the JSON limits too. The following setting will work unless there are other places in the code that are overriding these settings:

var bodyParser = require('body-parser');
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true, parameterLimit: 1000000}));

这篇关于Node.js错误:上传批量数据时参数太多错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆