From a0655f401bfd7650a3618fab652f28029df04465 Mon Sep 17 00:00:00 2001 From: a7458969 <290198252@qq.com> Date: Tue, 19 May 2020 02:05:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=BF=E4=B8=8A=E5=87=BA=E7=8E=B0too=20many?= =?UTF-8?q?=20open=20file=E9=94=99=E8=AF=AF=EF=BC=8C=E6=9F=A5=E6=98=8E?= =?UTF-8?q?=E6=98=AF=E5=9B=A0=E4=B8=BA=E6=89=93=E5=BC=80=E5=9B=BE=E5=83=8F?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=B2=A1=E6=9C=89=E5=85=B3=E9=97=AD=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/file.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controller/file.go b/controller/file.go index c69e772..9fe9e9d 100644 --- a/controller/file.go +++ b/controller/file.go @@ -192,6 +192,7 @@ func (this *FileController) OnThumbnail(c *gin.Context) { return } + defer file.Close() bytes,e :=ioutil.ReadAll(file) if nil != e{ log.Print(e.Error()) @@ -217,12 +218,14 @@ func (this *FileController) OnDownLoad(c *gin.Context) { return } file,e := os.Open(utils.GetCurrentDirectory() + "/image/" +fileName) + if nil != e{ log.Print(e.Error()) c.JSON(200,resp) return } + defer file.Close() bytes,e :=ioutil.ReadAll(file) if nil != e{ log.Print(e.Error())