0
我需要在回送模型中保存base64圖像。當我保存base64圖像時,我收到一個錯誤消息。我曾嘗試在中間件下同補充更新,我已經在了環回做之前,這個項目我升級到Loopback3接口,並陷入了這個問題,任何幫助將非常感激PayloadTooLargeError on loopback 3
堆棧跟蹤
Unhandled error for request POST /api/assets/{type}/upload: PayloadTooLargeError: request entity too large
at readStream (/project/node_modules/raw-body/index.js:155:17)
at getRawBody (/project/node_modules/raw-body/index.js:108:12)
at read (/project/node_modules/body-parser/lib/read.js:77:3)
at urlencodedParser (/project/node_modules/body-parser/lib/types/urlencoded.js:116:5)
at Layer.handle [as handle_request] (/project/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/project/node_modules/express/lib/router/index.js:317:13)
at /project/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/project/node_modules/express/lib/router/index.js:335:12)
at next (/project/node_modules/express/lib/router/index.js:275:10)
at jsonParser (/project/node_modules/body-parser/lib/types/json.js:118:7)
at Layer.handle [as handle_request] (/project/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/project/node_modules/express/lib/router/index.js:317:13)
at /project/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/project/node_modules/express/lib/router/index.js:335:12)
at next (/project/node_modules/express/lib/router/index.js:275:10)
at nosniff (/project/node_modules/dont-sniff-mimetype/index.js:4:5)
server.js
let loopback = require('loopback');
let boot = require('loopback-boot');
let bodyParser = require("body-parser");
let app = module.exports = loopback();
app.use(bodyParser.urlencoded({extended: true,limit:10485760}));
config.json
{
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 3000,
"remoting": {
"context": false,
"rest": {
"handleErrors": false,
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": 10485760
},
"urlencoded": {
"extended": true,
"limit": 10485760
},
"cors": false
},
"legacyExplorer": false,
"logoutSessionsOnSensitiveChanges": true
}
我也試圖在middleware.json
"parse": {
"body-parser#json": {
"limit": "52428800"
},
"body-parser#urlencoded": {
"params": {
"extended": true
},
"limit": "52428800"
}
},