feat(filetransfer): allow file deletion and add user delete config option (#683)

* feat(filetransfer): allow file deletion and add user delete config option

* fix(client): make user_delete required boolean in payload

* lint.

* feat(filetransfer): add confirmation dialog for file deletion.

* feat(filetransfer): add delete file confirmation messages in multiple languages

* lint.

---------

Co-authored-by: Miroslav Šedivý <sedivy.miro@gmail.com>
This commit is contained in:
Abdellatif Anaflous
2026-08-07 17:12:02 +01:00
committed by GitHub
parent 30d8e1c595
commit d6a4200b36
26 changed files with 205 additions and 10 deletions
+28
View File
@@ -388,6 +388,34 @@ func (h *LegacyHandler) Route(r types.Router) {
return err
})
r.Delete("/file", func(w http.ResponseWriter, r *http.Request) error {
if h.isBanned(r) {
return utils.HttpForbidden("banned ip")
}
s := h.newSession(r)
// create a new session
username := r.URL.Query().Get("usr")
password := r.URL.Query().Get("pwd")
err := s.create(username, password)
if err != nil {
return utils.HttpForbidden(err.Error())
}
defer s.destroy()
filename := r.URL.Query().Get("filename")
body, _, err := s.req(http.MethodDelete, "/api/filetransfer?filename="+url.QueryEscape(filename), r.Header, nil)
if err != nil {
return utils.HttpInternalServerError().WithInternalErr(err)
}
// copy the body to the response writer
_, err = io.Copy(w, body)
return err
})
r.Get("/health", func(w http.ResponseWriter, r *http.Request) error {
_, err := w.Write([]byte("true"))
return err
@@ -113,6 +113,7 @@ type FileTransferList struct {
Cwd string `json:"cwd"`
UserDownload bool `json:"user_download"`
UserUpload bool `json:"user_upload"`
UserDelete bool `json:"user_delete"`
Files []types.FileListItem `json:"files"`
}
@@ -611,6 +611,7 @@ func (s *session) wsToClient(msg []byte) error {
Cwd: request.RootDir,
UserDownload: request.UserDownload,
UserUpload: request.UserUpload,
UserDelete: request.UserDelete,
Files: files,
})