ggicci / httpin

🍡 HTTP Input for Go - HTTP Request from/to Go Struct (Bi-directional Data Binding between Go Struct and http.Request)
https://ggicci.github.io/httpin/
MIT License
315 stars 23 forks source link

Impossible to make streaming #88

Closed excavador closed 9 months ago

excavador commented 9 months ago

Imagine the case, when I would like to upload multiple large files. For instance, it could AWS S3 objects, or some large files from disk, or some other large content.

The following code - https://github.com/ggicci/httpin/blob/v0.15.2/core/requestbuilder.go#L151 - populate whole content inside bytes.Buffer.

Now imagine I am uploading the several GB of data...

Preferable way: use streaming. You could use io.Pipe (to divide source of data and destination) + + go-routine (to launch copy process under the hood + io.golang context (to cancel copy operation) + io.MultiReader (to combine multiple parts together)