diff --git a/connection_util.go b/connection_util.go index 4ab3e8344..a8b20726e 100644 --- a/connection_util.go +++ b/connection_util.go @@ -165,11 +165,11 @@ func getFileStream(ctx context.Context) (*bytes.Buffer, error) { // read a small amount of data to check if file stream will be used buf := make([]byte, defaultStringBufferSize) - _, err := r.Read(buf) + n, err := r.Read(buf) if err != nil { return nil, err } - return bytes.NewBuffer(buf), nil + return bytes.NewBuffer(buf[:n]), nil } func getFileTransferOptions(ctx context.Context) *SnowflakeFileTransferOptions {