feat: added downloading templated archives

This commit is contained in:
David Allen 2025-08-28 12:25:45 -06:00
parent 1ebea8cb73
commit 98f9acad5d
Signed by: towk
GPG key ID: 0430CDBE22619155
5 changed files with 48 additions and 23 deletions

View file

@ -53,13 +53,14 @@ func (s *Service) Download() http.HandlerFunc {
// determine if path is directory, file, or exists
if fileInfo, err = os.Stat(path); err == nil {
if fileInfo.IsDir() {
// get the final archive path
archivePath := fmt.Sprintf("%d.tar.gz", time.Now().Unix())
log.Debug().
Str("archive_path", archivePath).
Str("type", "directory").
Msg("Service.Download()")
// get the final archive path
archivePath := fmt.Sprintf("%d.tar.gz", time.Now().Unix())
out, err = os.Create(archivePath)
if err != nil {
s.writeErrorResponse(w, fmt.Sprintf("failed to create named file: %v", err), http.StatusInternalServerError)
@ -157,7 +158,7 @@ func (s *Service) Download() http.HandlerFunc {
s.writeErrorResponse(w, fmt.Sprintf("failed to get data from hook: %v", err), http.StatusInternalServerError)
return
}
w.Write([]byte(data.(string)))
w.Write(data.([]byte))
} else {
w.Write(contents)
}