Mongoose always buffers a full HTTP message before invoking MG_EV_HTTP_MSG event. Big POST request require of lot of RAM to buffer everything.

In order to upload large files to a memory-constrained system, use MG_EV_HTTP_CHUNK on a server side. It fires when a partial HTTP message has been received (or a chunk-encoded chunk). Use mg_http_delete_chunk() to release chunk memory. When 0-sized chunk is received, that's the end of the message. Use MG_MAX_RECV_BUF_SIZE build constant to limit maximum chunk size on a server side.

In this example, JavaScript code uses "fetch()" browser API. Uploaded file is not saved, but rather printed by server side.