月关宝盒
只需从请求正文中读取就像是package mainimport ("fmt";"net/http";"io/ioutil";"log")func h(w http.ResponseWriter, req *http.Request) { buf, err := ioutil.ReadAll(req.Body) if err!=nil {log.Fatal("request",err)} fmt.Println(buf) // do whatever you want with the binary file buf}一种更合理的方法是将文件复制到某个流中defer req.Body.Close()f, err := ioutil.TempFile("", "my_app_prefix")if err!=nil {log.Fatal("cannot open temp file", err)}defer f.Close()io.Copy(f, req.Body)