I want to test my http method that takes a post request and stores the given files.
func DownloadFiles(w http.ResponseWriter, r *http.Request) {
r.ParseMultipartForm(2097152) //2MB
files := r.MultipartForm.File["documents"] //files of type []*multipart.FileHeader
for _, handler := range files { //handler of type *multipart.FileHeader
file, err := handler.Open() //file of type multipart.File
... //Do something with files
}
w.WriteHeader(http.StatusOK)
}
How can i prepare a valid http.Request that features multipart-formdata and calls the function?