In client.go (current master, v1.22.66), addFile closes the opened file before calling io.Copy(part, file):
file, err := os.Open(filepath.Clean(path))
if err != nil {
return err
}
err = file.Close() // closes here...
...
_, err = io.Copy(part, file) // ...then reads from a closed file
Any multipart form-file upload prepared through this helper fails with file already closed.
Repro (Go 1.26):
// addFile(w, "file", tmpfile) always returns:
// read <tmpfile>: file already closed
Fix: close the file only after the copy (defer). I have a fix + regression test ready and will open a PR linked to this issue.
In
client.go(current master, v1.22.66),addFilecloses the opened file before callingio.Copy(part, file):Any multipart form-file upload prepared through this helper fails with
file already closed.Repro (Go 1.26):
Fix: close the file only after the copy (defer). I have a fix + regression test ready and will open a PR linked to this issue.