Implement getRequestFiles.

Co-authored-by: Hector Hurtado <hector.hurtado@bbva.com>
This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-10-18 10:06:26 +02:00
parent d2427b722c
commit e161e14fd6
2 changed files with 118 additions and 0 deletions
+11
View File
@@ -112,3 +112,14 @@ func getRequestFileName(w http.ResponseWriter, r *http.Request, h *model.Handler
w.WriteHeader(http.StatusNotFound)
}
}
func getRequestFileContent(w http.ResponseWriter, r *http.Request, h *model.Handler) {
w.Header().Add("Content-Type", "application/octet-stream")
name := mux.Vars(r)["name"]
file, _, err := h.Request.FormFile(name)
if err == nil {
_, _ = io.Copy(w, file)
} else {
w.WriteHeader(http.StatusNotFound)
}
}