You've already forked filebrowser
mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-11-26 14:25:26 +08:00
Merge pull request #727 from alexandrestein/weakClientFileName
Update download names file for weak clients
This commit is contained in:
2
frontend
2
frontend
Submodule frontend updated: 633579e738...ed5f51c3ff
@@ -2,6 +2,7 @@ package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/files"
|
||||
)
|
||||
@@ -10,7 +11,10 @@ var withHashFile = func(fn handleFunc) handleFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||
link, err := d.store.Share.GetByHash(r.URL.Path)
|
||||
if err != nil {
|
||||
return errToStatus(err), err
|
||||
link, err = d.store.Share.GetByHash(ifPathWithName(r))
|
||||
if err != nil {
|
||||
return errToStatus(err), err
|
||||
}
|
||||
}
|
||||
|
||||
user, err := d.store.Users.Get(d.server.Root, link.UserID)
|
||||
@@ -36,6 +40,12 @@ var withHashFile = func(fn handleFunc) handleFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func ifPathWithName(r *http.Request) string {
|
||||
pathElements := strings.Split(r.URL.Path, "/")
|
||||
id := pathElements[len(pathElements)-2]
|
||||
return id
|
||||
}
|
||||
|
||||
var publicShareHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||
return renderJSON(w, r, d.raw)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user