I am posting a csv file as a binary file using Postman REST API client. I need to get the filename of the uploaded file.
Here is a simple example of posting a csv file as binary data and storing the binary data as a csv file.
package main
import ( //"fmt"
"net/http"
"os"
"io"
"log"
"github.com/gorilla/mux"
)
func uploadData(w http.ResponseWriter, req *http.Request) {
file, err := os.Create("hello.csv")
_, err = io.Copy(file, req.Body)
_ = err
}
func main(){
router := mux.NewRouter()
router.HandleFunc("/parse", uploadData).Methods("POST")
log.Fatal(http.ListenAndServe(":8000", router))
}