Why do I get "The connection was reset" error when uploading a ~10MB file, and how to avoid reading the file into memory?

Hi everyone,

I’m running into an issue with my Go server when trying to upload files around 10MB using a simple file upload form. In my browser, I’m seeing a “The connection was reset” error, and I’m not sure what is causing this problem or how to fix it.

Here’s my current setup: https://go.dev/play/p/7TVn-njfeiH

When I attempt to upload a file around 10MB through this form, the browser gives me a “The connection was reset” error. I’ve verified that smaller files upload without any issues.

My uploadHandler currently does nothing but send a 200 OK status. Ideally, I’d like to process the file upload without reading it entirely into memory, to handle larger file uploads efficiently.

Can anyone help me understand why I’m getting this error and how to properly handle large file uploads without reading them completely into memory? Any guidance or examples would be greatly appreciated.

Thanks in advance!

There is an article explaining uploading in details. It might help with your situation