for {
buffer := make([]byte, 100000)
cBytes, err := part.Read(buffer)
if err == io.EOF {
break
}
read = read + int64(cBytes)
fmt.Printf("read: %v \n",read )
p = float32(read) / float32(length) * 100
fmt.Printf("progress: %v \n", p)
dst.Write(buffer[0:cBytes])
}
Should Read the following in the 'err == io.EOF' check because the part.Read(buffer) may have hit the EOF whilst reading the 'remaining' part of the file without filling the buffer so there's no subsequent parts but we still need to break.
if err == io.EOF {
if cBytes >= 1 && cBytes <= 100000 {
dst.Write(buffer[0:cBytes])
}
break
}
Should Read the following in the 'err == io.EOF' check because the part.Read(buffer) may have hit the EOF whilst reading the 'remaining' part of the file without filling the buffer so there's no subsequent parts but we still need to break.