fix file contents not being uploaded

This commit is contained in:
blek 2023-11-03 02:22:40 +10:00
parent 6e3367c81f
commit f08b427dd2
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 7 additions and 7 deletions

14
main.go
View File

@ -58,6 +58,13 @@ func upload(args *kong.Context) {
panic(err)
}
file, err := ioutil.ReadFile(Args.Upload.File)
if err != nil {
panic(err)
}
part.Write([]byte(file))
tosHeader := textproto.MIMEHeader{}
tosHeader.Set("Content-Type", "text/plain")
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"))
file, err := ioutil.ReadFile(Args.Upload.File)
if err != nil {
panic(err)
}
part.Write([]byte(file))
writer.Close()
req, err := http.NewRequest("POST", Args.Upload.Instance + "/curlapi/upload", body)