gin文件下载中文乱码解决

engine := gin.Default()
engine.GET("/up", func(c *gin.Context) {
	c.Header("Content-Type", "application/octet-stream")
	c.Header("Content-Disposition", fmt.Sprintf("attachment; filename*=utf-8''%s", url.QueryEscape("哈哈.png")))
	file, err := ioutil.ReadFile("file/abc.png")
	if err != nil {
		log.Println(err)
	}
	c.Writer.Write(file)
})
engine.Run("127.0.0.1:8888")

你可能感兴趣的:(go,golang,开发语言,后端)