1

I have my backend app deployed on GAE. Inside it, I am having an API which will upload a file to a GCS bucket. Recently I tried uploading a file of more than 50mb size and got 413 Request entity too large

Did some research and found out that the issue is with ngnix. The API will give 413 for any file > 32Mb.

Found one solution where it was mentioned to include a ngnix.conf file and add client_max_body_size 80M in it. I did so but still getting the same error.

This is my ngnix-app.conf file

server{
 location / {
        client_max_body_size       80m;
        client_body_buffer_size    512k;
  }
}

Anything obvious that I am missing out here?

Saptarshi Dey
  • 196
  • 3
  • 13
  • You can try adding parameterLimit in your bodyParser app.use(bodyParser.urlencoded({ "limit": "50mb", extended: true, parameterLimit: 1000000 })); This worked for me. – Amir Saleem Apr 30 '18 at 13:26
  • You could also compress the file on the client and de-compress on the server. – Chris Adams Apr 30 '18 at 13:34
  • @ChrisAdams actually the whole thing is happening in backend only. I have a schedule that takes backup of my database every night and then itself call the API to upload the backup SQL file in GCS bucket – Saptarshi Dey Apr 30 '18 at 13:38
  • Ah, yes, missed that in the Q, – Chris Adams Apr 30 '18 at 13:44
  • Please check the second edit [here](https://stackoverflow.com/a/19965089/3058302). You have to modify the maximum size in Node, like this: `app.use(bodyParser.json({limit: '50mb'}));` `app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));` – amport May 28 '18 at 07:46
  • similar with: https://stackoverflow.com/questions/27197856/node-nginx-413-request-entity-too-large-client-max-body-size-set/54140202#54140202 – pangpang Jan 11 '19 at 05:10

1 Answers1

6

You can change your request buffer size in your Node.Js application using

app.use(bodyParser.json({limit: '50mb'})); 
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));

Also you can increase your request in nginx configuration

server{
 location / {
        client_max_body_size       xxm;
        client_body_buffer_size    xxm;
  }
}
Kartik Raja S
  • 466
  • 3
  • 16