feat: 网元文件操作可删除本地临时文件

This commit is contained in:
TsMask
2024-08-21 16:31:04 +08:00
parent e4ad2088a1
commit deba4ca564
2 changed files with 27 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
package controller
import (
"os"
"path/filepath"
"be.ems/src/framework/i18n"
@@ -85,6 +86,7 @@ func (s *TcpdumpController) DumpDownload(c *gin.Context) {
NeType string `form:"neType" binding:"required"` // 网元类型
NeID string `form:"neId" binding:"required"` // 网元ID
TaskCode string `form:"taskCode" binding:"required"` // 任务码,停止任务并查看日志信息
DelTemp bool `form:"delTemp"` // 完成后是否删除本地临时zip文件
}
if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
@@ -96,6 +98,12 @@ func (s *TcpdumpController) DumpDownload(c *gin.Context) {
c.JSON(200, result.ErrMsg(i18n.TKey(language, err.Error())))
return
}
defer func() {
if query.DelTemp {
_ = os.Remove(zipFilePath)
}
}()
c.FileAttachment(zipFilePath, filepath.Base(zipFilePath))
}