I resolved this issue. I had to specify in the browser to encode as multipart/form-data and then on the server:
case http.MethodPost:
contentType := request.Header.Get("Content-Type")
if strings.HasPrefix(contentType, "multipart/form-data") {
p.DataBodyMap = make(url.Values, 0)
request.ParseMultipartForm(1000)
for key, value := range request.MultipartForm.Value {
p.DataBodyMap[key] = value
}
photoFile, header, err := request.FormFile("photoBytesString")
if err == nil {
log.Println(header, err)
photoContentType := header.Header["Content-Type"][0]
log.Println(photoContentType)
photoBytes, _ := ioutil.ReadAll(photoFile)
log.Println("len(photoBytes): ", len(photoBytes))
encodedImage64 := base64.StdEncoding.EncodeToString(photoBytes)
encodedImage64WithPrefix := "data:" + photoContentType + ";base64," + encodedImage64
p.DataBodyMap["photoBytesString"] = []string{encodedImage64WithPrefix}
}