feat(webdav): support range get
This commit is contained in:
@ -28,7 +28,16 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *base.Link, file *model.
|
||||
w.Header().Set("Content-Type", "application/octet-stream")
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename=%s`, url.QueryEscape(file.Name)))
|
||||
w.Header().Set("Content-Length", strconv.FormatInt(file.Size, 10))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if link.Header != nil {
|
||||
for h, val := range link.Header {
|
||||
w.Header()[h] = val
|
||||
}
|
||||
}
|
||||
if link.Status == 0 {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
} else {
|
||||
w.WriteHeader(link.Status)
|
||||
}
|
||||
_, err = io.Copy(w, link.Data)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -55,7 +55,7 @@ func Proxy(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
// 对于中转,不需要重设IP
|
||||
link, err := driver.Link(base.Args{Path: path}, account)
|
||||
link, err := driver.Link(base.Args{Path: path, Header: c.Request.Header}, account)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
|
@ -133,7 +133,7 @@ func (fs *FileSystem) Link(w http.ResponseWriter, r *http.Request, rawPath strin
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
link_, err := driver.Link(base.Args{Path: path_}, account)
|
||||
link_, err := driver.Link(base.Args{Path: path_, Header: r.Header}, account)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
Reference in New Issue
Block a user