Skip to content

Latest commit

 

History

History
38 lines (33 loc) · 914 Bytes

README.md

File metadata and controls

38 lines (33 loc) · 914 Bytes

Go Report Card License

safetyrecevier

golang package for receiving large file

install

go get -u github.com/joeke80215/safetyrecevier

receive

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
    }
}

read

safeReceive implement io.ReadSeeker interface
example

b, _ := ioutil.ReadAll(safeReceive)
.
.
.