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 11package example
22
33import (
4+ "os"
5+
46 "github.com/flipped-aurora/gin-vue-admin/server/global"
57 "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
68 "github.com/flipped-aurora/gin-vue-admin/server/model/example"
7- "github.com/flipped-aurora/gin-vue-admin/server/utils"
89 "github.com/gin-gonic/gin"
910 "go.uber.org/zap"
1011)
@@ -89,12 +90,18 @@ func (e *ExcelApi) LoadExcel(c *gin.Context) {
8990func (e * ExcelApi ) DownloadTemplate (c * gin.Context ) {
9091 fileName := c .Query ("fileName" )
9192 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 {
9496 global .GVA_LOG .Error ("文件不存在!" , zap .Error (err ))
9597 response .FailWithMessage ("文件不存在" , c )
9698 return
9799 }
100+ if fi .IsDir () {
101+ global .GVA_LOG .Error ("不支持下载文件夹!" , zap .Error (err ))
102+ response .FailWithMessage ("不支持下载文件夹" , c )
103+ return
104+ }
98105 c .Writer .Header ().Add ("success" , "true" )
99106 c .File (filePath )
100107}
You can’t perform that action at this time.
0 commit comments