feat(files): add archive content listing preview
ci / check (push) Successful in 1m12s

Lista conteudo de .zip, .tar, .tar.gz e .gz sem extrair, com limite anti-bomba.
This commit is contained in:
lgcosta committed 2026-11-06 09:55:56 -03:00
1 parent dc829b9d43
commit f6a74e1092
6 files changed
+389 -15

No files matched your search

+13
View File
@@ -55,6 +55,19 @@ func (s *Server) handleFileTree(w http.ResponseWriter, r *http.Request) {
})
}
// handleFileArchiveList devolve a listagem amigável do conteúdo de um
// compactado (.zip, .tar, .tar.gz/.tgz, .gz) sem extrair nada.
func (s *Server) handleFileArchiveList(w http.ResponseWriter, r *http.Request) {
entries, total, truncated, err := s.st.ListArchive(r.PathValue("id"))
if err != nil {
mapStoreErrorFor(w, err, "arquivo")
return
}
writeJSON(w, http.StatusOK, map[string]any{
"entries": entries, "total": total, "truncated": truncated,
})
}
func (s *Server) handleFileStatic(w http.ResponseWriter, r *http.Request) {
if err := s.st.ServeFile(w, r, r.PathValue("id")); err != nil {
mapStoreErrorFor(w, err, "arquivo")
+1
View File
@@ -98,6 +98,7 @@ func (s *Server) Handler() http.Handler {
// gerenciador de arquivos / anexos
mux.HandleFunc("POST /api/files/upload", s.auth(s.handleFileUpload))
mux.HandleFunc("GET /api/files/tree", s.auth(s.handleFileTree))
mux.HandleFunc("GET /api/files/archive/{id}", s.auth(s.handleFileArchiveList))
mux.HandleFunc("GET /api/files/static/{id}", s.auth(s.handleFileStatic))
mux.HandleFunc("DELETE /api/files/{id}", s.auth(s.handleFileDelete))
mux.HandleFunc("PUT /api/files/{id}/move", s.auth(s.handleFileMove))