fix file contents not being uploaded
This commit is contained in:
parent
6e3367c81f
commit
f08b427dd2
14
main.go
14
main.go
|
@ -58,6 +58,13 @@ func upload(args *kong.Context) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file, err := ioutil.ReadFile(Args.Upload.File)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
part.Write([]byte(file))
|
||||||
|
|
||||||
|
|
||||||
tosHeader := textproto.MIMEHeader{}
|
tosHeader := textproto.MIMEHeader{}
|
||||||
tosHeader.Set("Content-Type", "text/plain")
|
tosHeader.Set("Content-Type", "text/plain")
|
||||||
tosHeader.Set("Content-Disposition", fmt.Sprintf("form-data; name=\"tos_consent\"; filename=\"%s\"", Args.Upload.File))
|
tosHeader.Set("Content-Disposition", fmt.Sprintf("form-data; name=\"tos_consent\"; filename=\"%s\"", Args.Upload.File))
|
||||||
|
@ -67,13 +74,6 @@ func upload(args *kong.Context) {
|
||||||
}
|
}
|
||||||
tos.Write([]byte("on"))
|
tos.Write([]byte("on"))
|
||||||
|
|
||||||
file, err := ioutil.ReadFile(Args.Upload.File)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
part.Write([]byte(file))
|
|
||||||
|
|
||||||
writer.Close()
|
writer.Close()
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", Args.Upload.Instance + "/curlapi/upload", body)
|
req, err := http.NewRequest("POST", Args.Upload.Instance + "/curlapi/upload", body)
|
||||||
|
|
Loading…
Reference in New Issue