File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1
1
package example
2
2
3
3
import (
4
+ "os"
5
+
4
6
"github.com/flipped-aurora/gin-vue-admin/server/global"
5
7
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
6
8
"github.com/flipped-aurora/gin-vue-admin/server/model/example"
7
- "github.com/flipped-aurora/gin-vue-admin/server/utils"
8
9
"github.com/gin-gonic/gin"
9
10
"go.uber.org/zap"
10
11
)
@@ -89,12 +90,18 @@ func (e *ExcelApi) LoadExcel(c *gin.Context) {
89
90
func (e * ExcelApi ) DownloadTemplate (c * gin.Context ) {
90
91
fileName := c .Query ("fileName" )
91
92
filePath := global .GVA_CONFIG .Excel .Dir + fileName
92
- ok , err := utils .PathExists (filePath )
93
- if ! ok || err != nil {
93
+
94
+ fi , err := os .Stat (filePath )
95
+ if err != nil {
94
96
global .GVA_LOG .Error ("文件不存在!" , zap .Error (err ))
95
97
response .FailWithMessage ("文件不存在" , c )
96
98
return
97
99
}
100
+ if fi .IsDir () {
101
+ global .GVA_LOG .Error ("不支持下载文件夹!" , zap .Error (err ))
102
+ response .FailWithMessage ("不支持下载文件夹" , c )
103
+ return
104
+ }
98
105
c .Writer .Header ().Add ("success" , "true" )
99
106
c .File (filePath )
100
107
}
You can’t perform that action at this time.
0 commit comments