Closed alfaex closed 2 years ago
Thanks for opening your first issue here! π Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord
thanks for the report
i think we need a little time for this, as currently many of us are busy with other tasks
but we will take it into account and look at it, just want to say that it may take longer
@alfaex
you should set DisablePreParseMultipartForm
to true
by default, server reads the entire multipart message before calling the handler.
https://github.com/gofiber/fiber/blob/a7032b7a175a5f909413dc43600a8e505dca322e/app_test.go#L1558
Pre-read multipart form data of known length
https://github.com/valyala/fasthttp/blob/7a5afddf5b805a022f8e81281c772c11600da2f4/http.go#L1214
@bigflood it worked amazingly well
Problem solved.
Thanks.
@alfaex
you should set
DisablePreParseMultipartForm
to trueby default, server reads the entire multipart message before calling the handler.
https://github.com/gofiber/fiber/blob/a7032b7a175a5f909413dc43600a8e505dca322e/app_test.go#L1558
Pre-read multipart form data of known length
https://github.com/valyala/fasthttp/blob/7a5afddf5b805a022f8e81281c772c11600da2f4/http.go#L1214
I had problems uploading files that are other than image or text (pdf, exe, dlls...) but this fixed it all and works wonders. Thank you very much!!!
Fiber version v2.30.0
Issue description While studying stream upload multipart/form-data, for multiple large files, (2GB) in a small container with low memory.
I managed to do this with net/http with a docker container running with limited memory (32MB) and it worked, idle was using 5MB and while uploading 3GB files went to 10mb (limited chuncks to 1MB)
On Fiber it kept cashing the container because further reading about fasthttp it's stated that the whole body is read at once. link But at the end it's pointed to a solution StreamRequestBody
Everytime that I build the binary and use it in docker it crashes because it tried to use more than 32MB
The last thing I tried is to copy what net/http MultipartReader does using the
c.Context().RequestBodyStream()
Code snippet
Command to run the container
To check the memory I used this command.
Command to send the file
net/http example
Fiber example
Command to run the container
When trying to send the file like the previous one the container crashes
Command to send the file
The error reported from fiber (on docker it don't show the error, only when running
go run main.go
)Thanks β€ Fiber β€ππ₯