Skip to content

Commit

Permalink
修复文件名带空格无法下载的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
csznet committed Mar 5, 2024
1 parent 4e60ee0 commit dfbeada
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"csz.net/tgstate/utils"
)

// UploadImageAPI 上传文件api
// UploadImageAPI 上传图片api
func UploadImageAPI(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
if r.Method == http.MethodPost {
Expand Down Expand Up @@ -114,7 +114,7 @@ func D(w http.ResponseWriter, r *http.Request) {
// 输出文件内容到控制台
if string(buffer[:12]) == "tgstate-blob" {
content := string(buffer)
lines := strings.Fields(content)
lines := strings.Split(content, "\n")
log.Println("分块文件:" + lines[1])
w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Disposition", "attachment; filename=\""+lines[1]+"\"")
Expand Down

0 comments on commit dfbeada

Please sign in to comment.