diff --git a/server/file.go b/server/file.go index 3fb7c84..efd466f 100644 --- a/server/file.go +++ b/server/file.go @@ -11,7 +11,6 @@ func handleFile(w http.ResponseWriter, r *http.Request) { http.Error(w, "No id", http.StatusBadRequest) return } - // TODO check if worker is working on a task involving this file var path string @@ -22,5 +21,25 @@ func handleFile(w http.ResponseWriter, r *http.Request) { return } + slog.InfoContext(r.Context(), "Serving File Download", "id", id, "path", path) + + // had timeout issues http.ServeFile(w, r, path) + + /* + reader, err := os.Open(path) + if err != nil { + http.Error(w, "Error Opening File: "+err.Error(), http.StatusInternalServerError) + slog.ErrorContext(r.Context(), "Opening File", "err", err) + return + } + + w.Header().Set("Content-Disposition", "attachment;filename="+filepath.Base(path)) + _, err = io.Copy(w, reader) + if err != nil { + http.Error(w, "Copy File: "+err.Error(), http.StatusBadRequest) + slog.ErrorContext(r.Context(), "Copy File", "err", err) + return + } + */ }