Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
fix multi-part
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Jul 15, 2019
1 parent b0c0898 commit 90eb22b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cmd/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 90eb22b

Please sign in to comment.