I have two services running as microservices, I get file from user using Service-1
and then try to POST
it to Service-2
, where it will be read and processed.
Here what I had tried.
Service-1:
Form data is taken as:
<form class="formContainer" id="my_form" action="http://usagemeter:7171/addmanagerstouser">
</form>
Controller:
adduserManagersReq := adminservice+"/addmanagerstouser"
usagerManagersCsv := req.FormValue("user_managers")
adduserManagersRes, err := http.PostForm(adduserManagersReq, url.Values{"usermanagers": {usagerManagersCsv}})
Here csv is passed as user_manager
in html form.
Service-2:
func addManagersToUsers(res http.ResponseWriter,req *http.Request){
file := req.FormValue("usermanagers")
fd, err := os.Open(file)
if err != nil {
log.Println("Error opening file")
fmt.Fprintf(res,"false")
return
}
defer fd.Close()
}
Here I get No such file or directory
.
What am I missing here? Is this possible? or have to use another way to do it?