fix(webconsole): sftp download utf8 filename (#19709)

This commit is contained in:
屈轩
2024-03-12 18:29:06 +08:00
committed by GitHub
parent 299846783d
commit 25a2f3a3ed
+3 -1
View File
@@ -20,8 +20,10 @@ import (
"io"
"io/fs"
"net/http"
"net/url"
"path"
"sort"
"strings"
"sync"
"time"
@@ -245,7 +247,7 @@ func HandleSftpDownload(ctx context.Context, w http.ResponseWriter, r *http.Requ
}
defer reader.Close()
w.Header().Add("Content-Disposition", "attachment;filename="+file.Name())
w.Header().Add("Content-Disposition", "attachment;filename*=utf-8''"+strings.ReplaceAll(url.QueryEscape(file.Name()), "+", "%20"))
w.Header().Add("Content-Type", "application/octet-stream")
_, err = io.Copy(w, reader)
return err