From d33597766a56f123b5c571ed9d1cb6a75b096c6a Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Fri, 30 Aug 2024 15:47:57 +0800 Subject: [PATCH] download file --- handler/tool.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/handler/tool.go b/handler/tool.go index 06247d7..8cb42bd 100644 --- a/handler/tool.go +++ b/handler/tool.go @@ -93,11 +93,6 @@ func DownloadFile(c *gin.Context) { defer file.Close() // 设置响应头 - c.Writer.Header().Set("Content-Description", "File Transfer") - c.Writer.Header().Set("Content-Transfer-Encoding", "binary") - c.Writer.Header().Set("Expires", "0") - c.Writer.Header().Set("Cache-Control", "must-revalidate") - c.Writer.Header().Set("Pragma", "public") c.Writer.Header().Set("Content-Type", "application/octet-stream") c.Writer.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", file_.FileName)) @@ -107,6 +102,8 @@ func DownloadFile(c *gin.Context) { c.JSON(http.StatusInternalServerError, gin.H{"error": "Internal Server Error", "message": "Failed to send file"}) return } + + c.Status(http.StatusOK) } func SetRedis(c *gin.Context) {