Compare commits

..

No commits in common. "c3c43b0079be344faca8602e98b6c2887b893fcd" and "1b79a6cd36985978492f9ecd376b669a32e8af42" have entirely different histories.

1 changed files with 5 additions and 2 deletions

View File

@ -93,6 +93,11 @@ func DownloadFile(c *gin.Context) {
defer file.Close() 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-Type", "application/octet-stream")
c.Writer.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", file_.FileName)) c.Writer.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", file_.FileName))
@ -102,8 +107,6 @@ func DownloadFile(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Internal Server Error", "message": "Failed to send file"}) c.JSON(http.StatusInternalServerError, gin.H{"error": "Internal Server Error", "message": "Failed to send file"})
return return
} }
c.Status(http.StatusOK)
} }
func SetRedis(c *gin.Context) { func SetRedis(c *gin.Context) {