Fix garbled/mojibake text display issues for non-English Unicode characters in browsers. (#441)

* Update util.go

Fix garbled/mojibake text display issues for non-English Unicode characters in browsers.

* add Content-Disposition, help handle file name on download

Author:    awkj <hzzbiu@gmail.com>
This commit is contained in:
awkj
2025-03-17 23:22:54 +08:00
committed by GitHub
parent d53885c541
commit da0b440360
2 changed files with 16 additions and 4 deletions

View File

@ -21,7 +21,9 @@ func RawFile(ctx *context.Context) error {
return ctx.NotFound("File not found")
}
contentType := handlers.GetContentTypeFromFilename(file.Filename)
ContentDisposition := handlers.GetContentDisposition(file.Filename)
ctx.Response().Header().Set("Content-Type", contentType)
ctx.Response().Header().Set("Content-Disposition", ContentDisposition)
return ctx.PlainText(200, file.Content)
}