Add POST /files to store an uploaded file inside a home folder

The handler reuses the home-path resolution of GET /files, refuses special
filesystems and non-directories, writes with O_EXCL so an existing name is
answered 409 instead of overwritten, enforces the chat upload size limit and
replies with the stored name, path and size.
This commit is contained in:
2026-11-08 23:57:53 +00:00
parent c2d8d6d7a3
commit 81460c4a4d
3 changed files with 303 additions and 0 deletions
+1
View File
@@ -155,6 +155,7 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
})
mux.HandleFunc("GET /discovery", serveServerDiscovery)
mux.HandleFunc("GET /files", serveHomeFile)
mux.HandleFunc("POST /files", serveHomeFileUpload)
mux.HandleFunc("POST /chat-uploads", serveChatUpload)
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")