```
package main
import (
"fmt"
_ "net/http"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.POST("/upload3", func(c *gin.Context) {
id := c.Query("id") //解析url中id的值
page := c.DefaultQuery("page", "0") //解析page的值,page默认为0
name := c.Request.Header.Get("name") //得到headers中name的值
//message := c.postfrom("message")
fmt.Printf("id: %s; page: %s; name: %s\n", id, page, name)
mr, _ := c.Request.MultipartReader()
for {
p, _ := mr.NextPart() //得到body中字段名字
if p == nil {
break
}
MetaData := make([]byte, 100000)
n, err := p.Read(MetaData) //数据大于4042会截断
if err != nil {
fmt.Println(n, err)
break
}
fmt.Println(p.FormName(), string(MetaData))
fmt.Println("size", n)
}
})
router.Run(":8081")
}
```
上传的文件大小大于4042时会截断,为什么???