1

I am sending an image file from an android client along with some other data. The image is sent as a Base64 string. I am trying to store the image in the server but it returns a 413 http status code.

Some solutions suggested increasing the body-parser limit using, app.use(bodyParser({limit: '50mb'}));, but the code is not in the launcher file app.js. How can I do that in another file?

ashwin mahajan
  • 1,654
  • 5
  • 27
  • 50
  • The `app.use(bodyParser({limit: '50mb'}));` is a middleware, it means that no matter what, the function will be called before you enter your route. So there is no point to move it away from the app.js – krakig Nov 02 '16 at 15:59

2 Answers2

1

This fixed it for me: app.use(bodyParser.json({limit: '20mb'}));

andyrandy
  • 72,880
  • 8
  • 113
  • 130
0

I was using express framework & in my case below approach fixed 413 error:-

var app = express();

app.use(express.json({limit:'50mb'})); // for incoming Request Object as json

app.use(express.urlencoded({limit:'50mb', extended: true })); // for content-type = application/ x-www-form-urlencoded 
vivek sharma
  • 251
  • 3
  • 11