From 68654f8bd3998402fefddf07381e284fccd1775e Mon Sep 17 00:00:00 2001 From: codeskyblue Date: Thu, 11 May 2017 16:47:17 +0800 Subject: [PATCH] add some log --- httpstaticserver.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/httpstaticserver.go b/httpstaticserver.go index 16f6f5f..2469102 100644 --- a/httpstaticserver.go +++ b/httpstaticserver.go @@ -143,13 +143,15 @@ func (s *HTTPStaticServer) hUpload(w http.ResponseWriter, req *http.Request) { file, header, err := req.FormFile("file") if err != nil { + log.Println("Parse form file:", err) http.Error(w, err.Error(), http.StatusInternalServerError) return } defer file.Close() - dst, err := os.Create(filepath.Join(dirpath, header.Filename)) // BUG(ssx): There is a leak here + dst, err := os.Create(filepath.Join(dirpath, header.Filename)) if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) + log.Println("Create file:", err) + http.Error(w, "File create "+err.Error(), http.StatusInternalServerError) return } defer dst.Close() @@ -158,7 +160,6 @@ func (s *HTTPStaticServer) hUpload(w http.ResponseWriter, req *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - // runtime.GC() w.Write([]byte("Upload success")) }