diff --git a/pkg/piecestore/rpc/client/client.go b/pkg/piecestore/rpc/client/client.go index a86d0ad27..05a82b4a1 100644 --- a/pkg/piecestore/rpc/client/client.go +++ b/pkg/piecestore/rpc/client/client.go @@ -4,6 +4,7 @@ package client import ( + "bufio" "fmt" "io" "log" @@ -76,9 +77,12 @@ func (client *Client) Put(ctx context.Context, id PieceID, data io.Reader, ttl t } }() - _, err = io.Copy(writer, data) - - return err + bufw := bufio.NewWriterSize(writer, 32*1024) + _, err = io.Copy(bufw, data) + if err != nil { + return err + } + return bufw.Flush() } // Get begins downloading a Piece from a piece store Server