Greetings

I'm having some trouble while uploading medium-sized files (>6MB) through a 
POST request. The browser client gives me the error 'Connection reset'. 
I've tried using both the default *gin.Engine and vanilla http.Server (with 
ReadTimeout and WriteTimeout in zeros). When the error appears, seems like 
the request call doesn't reach my UploadFile function.

It seem to me that it is a read timeout issue, but changing the default 
timeout in the server hadn't helped.

Any idea what's wrong with this?

//This is the handlerFunc code
func UploadFile(c *gin.Context) {
 fmt.Println("Starting handler") //when the file is large, this isn't 
printed
 file, header, ex := c.Request.FormFile("upload")

 if ex != nil {
 c.JSON(http.StatusBadRequest, ex)
 return
 }
 nf, ex := os.Create("newFile")

 defer nf.Close()
 if ex != nil {
 c.AbortWithStatus(http.StatusInternalServerError)
 }
 _, ex := io.Copy(nf, file)
 if ex != nil {
   c.AbortWithStatus(http.StatusInternalServerError)
 }
}

//I've tried serving this way
server := &http.Server{
ReadTimeout:  0,
WriteTimeout: 0,
Handler:      r, // r is an *gin.Engine
Addr:         port,
}
server.ListenAndServe()
//and this way
r.Run(port)



-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to