[英]Change http request limit in Sailsjs
I'm having a 413 Request Entity Too Large in a request, because I send several URI Image base64 encoded, and that's a lot of characters. 我的请求中有413个请求实体太大,因为我发送了多个以base64编码的URI图像,而且字符很多。
Anyway, I can't find a way to extend this limit in SailJS. 无论如何,我找不到在SailJS中扩展此限制的方法。 Apparently Sails use Skipper for the bodyParser, but I can't find anything in the skipper doc. 显然,Sails使用Skipper作为bodyParser,但在船长文档中找不到任何内容。
I guess it's in the http config file... 我猜它在http配置文件中...
If someone can tell me how :) Thanks ! 如果有人可以告诉我如何:)谢谢!
AFAIK it's configurable when you create controller that handle that uploads, like: AFAIK在创建处理上传的控制器时是可配置的,例如:
req.file('avatar').upload({
maxBytes : 2000000 // integer
}, function (err, uploadedFiles) {
if (err) return res.send(500, err);
return res.json({
message: uploadedFiles.length + ' file(s) uploaded successfully!',
files: uploadedFiles
});
});
But they said it's currently still experimental. 但是他们说目前仍在试验中。 Look at this Skipper's Docs . 看一下此船长的文档 。
This solution worked for us https://github.com/balderdashy/sails/issues/2653 该解决方案为我们工作https://github.com/balderdashy/sails/issues/2653
Sails is using skipper for body parser. Sails正在使用主体分析器的船长 。 You can configure or change default skipper configuration by creating a middleware in config/http.js: 您可以通过在config / http.js中创建一个中间件来配置或更改默认的船长配置:
configuredSkipperBodyParser: function () {
var opts = {limit:'50mb'};
var fn;
// Default to built-in bodyParser:
fn = require('skipper');
return fn(opts);
}
Then set it instead of default body parser: 然后设置它而不是默认的正文解析器:
order: [
'startRequestTimer',
'cookieParser',
'session',
'myRequestLogger',
'configuredSkipperBodyParser',
'handleBodyParserError',
'compress',
'methodOverride',
'poweredBy',
'$custom',
'router',
'www',
'favicon',
'404',
'500'
]
Hope this is helpful. 希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.