func New(ue *uploadinfo.Entry, compressed bool, chunkSize int) (*Chunker, error) {
	if chunkSize < 1 {
		chunkSize = DefaultChunkSize
	}
	var c *Chunker
	if ue.IsBlob() {
		contents := make([]byte, len(ue.Contents))
		copy(contents, ue.Contents)
		if compressed {
			contents = fullCompressor.EncodeAll(contents, nil)
		}
		c = &Chunker{
			contents: contents,
		}
	} else if ue.IsFile() {
		r := reader.NewFileReadSeeker(ue.Path, IOBufferSize)
		if compressed {
			var err error
			r, err = reader.NewCompressedSeeker(r)
			if err != nil {
				return nil, err
			}
		}
		c = &Chunker{
			r: r,
		}
		if chunkSize > IOBufferSize {
			chunkSize = IOBufferSize
		}
	} else {
		return nil, errors.New("invalid Entry")
	}
	c.chunkSize = chunkSize
	c.ue = ue
	return c, nil
}
New creates a new chunker from an uploadinfo.Entry.
If compressed, the data will of the Entry will be compressed on the fly.
package chunker
import (
	"fmt"
	"io"
	"io/ioutil"
	"github.com/klauspost/compress/zstd"
	"github.com/pkg/errors"
	"github.com/bazelbuild/remote-apis-sdks/go/pkg/reader"
	"github.com/bazelbuild/remote-apis-sdks/go/pkg/uploadinfo"
)
const DefaultChunkSize = 1024 * 1024
var IOBufferSize = 10 * 1024 * 1024
var ErrEOF = errors.New("ErrEOF")
var fullCompressor, _ = zstd.NewWriter(nil, zstd.WithZeroFrames(true))
type Chunker struct {
	chunkSize int
	r         reader.ReadSeeker
	contents   []byte
	offset     int64
	reachedEOF bool
	ue *uploadinfo.Entry
}