线上出现too many open file错误,查明是因为打开图像文件没有关闭导致的
parent
a050f8928b
commit
a0655f401b
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue