kataras / iris

The fastest HTTP/2 Go Web Framework. New, modern and easy to learn. Fast development with Code you control. Unbeatable cost-performance ratio :rocket:
https://www.iris-go.com
BSD 3-Clause "New" or "Revised" License
25.23k stars 2.47k forks source link

[FEATURE REQUEST] Is there anyway to upload large files with low memory cost? #1684

Open flykarry opened 3 years ago

flykarry commented 3 years ago

Is your feature request related to a problem? Please describe. when I upload a large files ,It's may cost too large memory

Describe the solution you'd like separate the file with many chunk upload, and then merge and save

Describe alternatives you've considered nothing

Additional context nothing

kataras commented 3 years ago

Hello @flykarry,

There is no a builtin feature like this, I think it will be better if you have just opened this issue at https://github.com/golang/go, as the underline functionality we use to receive uploaded files derived from net/http package (otherwise we would have to duplicate a lot of code for such a feature). However, I assume you can use a rate limiter/a throttler for that (like we do on ServeContentWithRate(content io.ReadSeeker, filename string, modtime time.Time, limit float64, burst int) to send files to the client) , but you have to parse the body correctly as net/http does ( per HTTP/1.1 and 2.0 specification). This is a good feature request but, I don't think that's the right moment as we will ship the v12.2.0 stable release soon.

I will leave this feature request open so we can get feedback from other developers too, maybe we'll find time for that, but I can't promise you anything yet.

tuhao1020 commented 3 years ago

https://www.threeaccents.com/posts/handling-large-file-uploads-in-go may be helpful for you @flykarry