线上出现too many open file错误,查明是因为打开图像文件没有关闭导致的

master
a7458969 2020-05-19 02:05:57 +08:00
parent a050f8928b
commit a0655f401b
1 changed files with 3 additions and 0 deletions

View File

@ -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())