golang package for receiving large file
go get -u github.com/joeke80215/safetyrecevier
maxMemoeryBufSize := 4 << 20
safeReceive := softrecevier.New(maxMemoeryBufSize)
defer safeReceive.CloseReceive()
for {
chunk := make([]byte, 3) // set any chunk size
n, err := exampleReader.Read(chunk)
if err := safeReceive.Append(chunk,n);err != nil {
if err == io.EOF {
break
}
// handle error
}
}
safeReceive implement io.ReadSeeker interface
example
b, _ := ioutil.ReadAll(safeReceive)
.
.
.