It seems that it should copy just after createFormFile in the postMultipartFile function, otherwise It will raise multipart: can't write to finished part error.
formWriter, err := writer.CreateFormFile("torrents", path.Base(fileName))
if err != nil {
return nil, fmt.Errorf("error adding file: %w", err)
}
// copy the file first or there will be "multipart: can't write to finished part" error
// copy the file contents into the form
if _, err = io.Copy(formWriter, file); err != nil {
return nil, fmt.Errorf("error copying file: %w", err)
}
// write the options to the buffer
writeOptions(writer, opts)
It seems that it should copy just after createFormFile in the postMultipartFile function, otherwise It will raise
multipart: can't write to finished part
error.https://github.com/NullpointerW/go-qbittorrent-apiv2/blob/9b515d3fcfaf4f8e951a48d100d055cbda590f6c/cli.go#L144-L155
I change the code to the below to make it work.