Maximum Body Size for Netlify Function Post

I am trying to upload an image to Cloudinary by way of a Netlify Function. I am sending the base64 encoded string representation of an image file from the browser to the serverless function. This call crashes occasionally when the max POST body size is exceeded (with a hi-res image).

Is there a formal limit in the documentation somewhere for how big the data in the POST body can be?

1 Like

Hi James,

That’s a curious issue. I’ve checked with a colleague and we’ve seen functions accept up to 6mb files. That said, I think you might be more likely running into the function runtime limit of 10 seconds. Could you perhaps get the request-id of a request that failed as you described?

You can view here: [Support Guide] Netlify Support asked for the 'x-nf-request-id' header? What is it and how do I find it? in case you need some guidance on how to get that information.

1 Like

Thanks for the feedback! How would I go about finding the request-id?

Hi, @jamesqquick, the link sent has more information about how to find the x-nf-request-id header value:

I’m wondering if there is a stated limit somewhere as James originally asked for? I get an error immediately with a base64 encoded image that is 4.69 MB. Smaller images are fine. I’m going to see if I can find the threshold.

Here’s the specific error: Error: Stream body too big
at IncomingMessage.onData (C:\Users\DaveGray\AppData\Roaming\npm\node_modules\netlify-cli\src\utils\create-stream-promise.js:24:16)

Hi, @gitdagray and @jamesqquick. The limit for a POST with a Function is determined by the limits of the underlying infrastructure. That infrastructure is AWS Lambda and the limits are listed here:


Resource Quota
Invocation payload (request and response) 6 MB (synchronous)

My guess is that when base64 encoded, the size of the image data is then over the 6 MB limit (as it is no longer in the more compact binary format).

Note, I’m specifically referring to POST limits for Functions here.

If there are other questions, please let us know.