Skip to content

Commit

Permalink
fix(proxy): filename is urlencoded when using Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
XZB-1248 committed Jun 2, 2022
1 parent f6be50f commit 7c6d8ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/common/proxy.go
Expand Up @@ -26,7 +26,7 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *base.Link, file *model.
_ = link.Data.Close()
}()
w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename=%s`, file.Name))
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"; filename*=UTF-8''%s`, file.Name, url.QueryEscape(file.Name)))
w.Header().Set("Content-Length", strconv.FormatInt(file.Size, 10))
if link.Header != nil {
for h, val := range link.Header {
Expand Down Expand Up @@ -57,7 +57,7 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *base.Link, file *model.
if err != nil {
return err
}
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename=%s`, url.QueryEscape(file.Name)))
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"; filename*=UTF-8''%s`, file.Name, url.QueryEscape(file.Name)))
http.ServeContent(w, r, file.Name, fileStat.ModTime(), f)
return nil
} else {
Expand Down

0 comments on commit 7c6d8ca

Please sign in to comment.