debug eof

This commit is contained in:
Samuel Lorch 2024-05-11 00:43:34 +02:00
parent 78d818b8d1
commit 981b745c9e

View file

@ -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
}
*/
}