文件上传
简易文件上传
app.Get("/hello", func(ctx *erguotou.Context) {
// FormFile 读取文件
header, e := ctx.FormFile("file")
if e != nil {
ctx.String(400,"")
}
file, e := header.Open()
if header != nil {
defer file.Close()
}
bytes, e := ioutil.ReadAll(file)
if e == nil {
// SeedFile 发送文件
ctx.SeedFileByte(bytes)
}
})
设置文件上传大小
err := app.Run(erguotou.SetHost(":8081"), erguotou.SetDebug(false),erguotou.SetUploadSize(8 << 20)) // 8M