diff --git a/upload.go b/upload.go index 95f2ade..bd0d3d1 100644 --- a/upload.go +++ b/upload.go @@ -52,3 +52,19 @@ func postFileForm(filename string, targetURL string, formFieldName string) (strJ fmt.Println(string(strJSON)) return strJSON, nil } + +func postJSON(jsonB []byte, targetURL string) (resp string, err error) { + req, err := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonB)) + if err != nil { + return + } + client := &http.Client{} + r, err := client.Do(req) + if err != nil { + return + } + defer r.Body.Close() + b, _ := ioutil.ReadAll(r.Body) + resp = string(b) + return +}