From 90eb22b26a23fae152ced79a8ae0d7a9bb5d364d Mon Sep 17 00:00:00 2001 From: Nandan Sridhar Date: Sun, 14 Jul 2019 23:40:08 -0700 Subject: [PATCH] fix multi-part --- cmd/shared/shared.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cmd/shared/shared.go b/cmd/shared/shared.go index eba326ec..bc9db72c 100644 --- a/cmd/shared/shared.go +++ b/cmd/shared/shared.go @@ -10,6 +10,7 @@ import ( "github.com/lestrrat/go-jwx/jwa" "github.com/lestrrat/go-jwx/jwt" "github.com/spf13/viper" + "io" "io/ioutil" "log" "mime/multipart" @@ -119,13 +120,27 @@ func GetHttpClient(url string) error { func PostHttpOctet(url string, proxyName string) error { - file, err := os.Open(proxyName) + file, _ := os.Open(proxyName) defer file.Close() body := &bytes.Buffer{} writer := multipart.NewWriter(body) + part, err := writer.CreateFormFile("proxy",proxyName) + if err != nil { + Error.Fatalln("Error writing multi-part:\n", err) + return err + } + _, err = io.Copy(part, file) + if err != nil { + Error.Fatalln("Error copying multi-part:\n", err) + return err + } + err = writer.Close() - + if err != nil { + Error.Fatalln("Error closing multi-part:\n", err) + return err + } client := &http.Client{} Info.Println("Connecting to : ", url)