fix: use io.Reader after copy

Signed-off-by: Ben Tam <master@murasakiakari.moe>
This commit is contained in:
Ben Tam 2023-10-30 01:40:09 +08:00
parent c6155fbcae
commit df102c9cec
No known key found for this signature in database
GPG Key ID: FD345C984C044DC0

View File

@ -435,10 +435,14 @@ func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) (err
return err
}
} else {
contentLength, err = io.Copy(io.Discard, stream)
buffer := bytes.NewBuffer(make([]byte, 0, 1024 * 1024 /* 1MB */))
contentLength, err = io.Copy(buffer, stream)
if err != nil {
return err
}
stream = buffer
}
s, err := c.put(path, stream, contentLength)