mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 18:20:54 +00:00
QueryEscape Download File Name
This commit is contained in:
parent
520a417cca
commit
830985b90b
@ -24,6 +24,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -244,13 +245,15 @@ func (output *BeegoOutput) Download(file string, filename ...string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var fName string
|
||||||
|
if len(filename) > 0 && filename[0] != "" {
|
||||||
|
fName = filename[0]
|
||||||
|
} else {
|
||||||
|
fName = filepath.Base(file)
|
||||||
|
}
|
||||||
|
output.Header("Content-Disposition", "attachment; filename="+url.QueryEscape(fName))
|
||||||
output.Header("Content-Description", "File Transfer")
|
output.Header("Content-Description", "File Transfer")
|
||||||
output.Header("Content-Type", "application/octet-stream")
|
output.Header("Content-Type", "application/octet-stream")
|
||||||
if len(filename) > 0 && filename[0] != "" {
|
|
||||||
output.Header("Content-Disposition", "attachment; filename="+filename[0])
|
|
||||||
} else {
|
|
||||||
output.Header("Content-Disposition", "attachment; filename="+filepath.Base(file))
|
|
||||||
}
|
|
||||||
output.Header("Content-Transfer-Encoding", "binary")
|
output.Header("Content-Transfer-Encoding", "binary")
|
||||||
output.Header("Expires", "0")
|
output.Header("Expires", "0")
|
||||||
output.Header("Cache-Control", "must-revalidate")
|
output.Header("Cache-Control", "must-revalidate")
|
||||||
|
Loading…
Reference in New Issue
Block a user