diff --git a/dsSzxy/build/dsSzxy b/dsSzxy/build/dsSzxy index b17a183e..fc429138 100644 Binary files a/dsSzxy/build/dsSzxy and b/dsSzxy/build/dsSzxy differ diff --git a/dsSzxy/main.go b/dsSzxy/main.go index c9425319..03b5473a 100644 --- a/dsSzxy/main.go +++ b/dsSzxy/main.go @@ -15,10 +15,20 @@ import ( "io/ioutil" "log" "net/http" + "net/url" "os" "strings" ) +/** +功能:生成下载地址带中文名 +*/ +func getFileDownLoadUrl(key string, originName string) string { + infix := "?response-content-disposition=attachment%3BfileName%2A%3DUTF-8%27%27" + downloadUrl := ConfigUtil.Download_prefix + ConfigUtil.Minio_bucket + "/" + key + infix + url.QueryEscape(url.QueryEscape(originName)) + return downloadUrl +} + // @title 东师理想智慧校园支撑系统 // @version 2.0 // @description @@ -88,6 +98,9 @@ func main() { log.Fatalln(err) } + //返回 + s := getFileDownLoadUrl(trueName[0:2]+"/"+trueName, file.Filename) + //判断扩展名是不是图片 if ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".bmp" { //读取本地文件 @@ -119,10 +132,10 @@ func main() { os.Remove(filename) //删除缩略图文件 os.Remove(thumbTrueName) - //返回 + c.JSON(200, gin.H{ "success": true, - "url": ConfigUtil.Download_prefix+trueName[0:2] + "/" + trueName, + "url": s, "thumbContent": sourceString, "size": size, }) @@ -131,7 +144,7 @@ func main() { os.Remove(filename) c.JSON(200, gin.H{ "success": true, - "url": ConfigUtil.Download_prefix+trueName[0:2] + "/" + trueName, + "url": s, "size": size, }) }