fix: get file content twice (#2000)

This commit is contained in:
Ns2Kracy 2024-09-14 23:21:03 +08:00 committed by GitHub
parent e4bf67dad5
commit 8b251dc407
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -257,7 +257,6 @@ func GetDownloadSingleFile(ctx echo.Context) error {
ctx.Request().Header.Add("Content-Length", strconv.FormatInt(node.Size(), 10)) ctx.Request().Header.Add("Content-Length", strconv.FormatInt(node.Size(), 10))
} }
http.ServeContent(ctx.Response().Writer, ctx.Request(), fileName, node.ModTime(), fi) http.ServeContent(ctx.Response().Writer, ctx.Request(), fileName, node.ModTime(), fi)
// http.ServeFile(c.Writer, ctx.Request(), filePath)
defer fi.Close() defer fi.Close()
fileTmp, err := os.Open(filePath) fileTmp, err := os.Open(filePath)
if err != nil { if err != nil {
@ -268,7 +267,7 @@ func GetDownloadSingleFile(ctx echo.Context) error {
} }
defer fileTmp.Close() defer fileTmp.Close()
return ctx.File(filePath) return nil
} }
// @Summary 获取目录列表 // @Summary 获取目录列表