Fix: add filename when download file
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
@@ -111,6 +112,12 @@ func (api *API) HandleGetFileDirect(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// set header for filename
|
||||
filename := file.Filename
|
||||
// encode filename to URL
|
||||
filename = url.PathEscape(filename)
|
||||
w.Header().Set("Content-Disposition", "inline; filename*=UTF-8''"+filename)
|
||||
|
||||
log.Println("[api] Get direct raw file", path)
|
||||
|
||||
http.ServeFile(w, r, path)
|
||||
|
||||
Reference in New Issue
Block a user