I want to submit a get request with a large file payload (up to several gbs) to a golang server, but rather than having it store the multi-part body on the file system and then copy the file contents to a buffer and forward it on, I'd like to forward the body of the request to another service as it arrives (without storing anything). Here is a modified (from How can I receive an uploaded file using a Golang net/http server?) non-working example for a post request:
func ReceiveFile(w http.ResponseWriter, r *http.Request) {
var Buf bytes.Buffer
file, header, err := r.FormFile("file")
if err != nil {
panic(err)
}
defer file.Close()
io.Copy(&Buf, file)
// stream Buf to grpc server
Buf.Reset()
return
}