Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRangeRequestsNotSupported is returned by Seek and Read // when the remote server does not allow range requests (Accept-Ranges was not set) ErrRangeRequestsNotSupported = errors.New("range requests are not supported by the remote server") // ErrInvalidRange is returned by Read when trying to read past the end of the file ErrInvalidRange = errors.New("invalid range") // ErrContentHasChanged is returned by Read when the content has changed since the first request ErrContentHasChanged = errors.New("content has changed since first request") )
Functions ¶
This section is empty.
Types ¶
type RangedReader ¶
type RangedReader struct { Resource *Resource // contains filtered or unexported fields }
RangedReader for a resource. Implements the io.ReaderAt interface that can be used with Go's archive/zip package.
func NewRangedReader ¶
func NewRangedReader(resource *Resource) *RangedReader
NewRangedReader creates a RangedReader object on a given resource
func (*RangedReader) ReadAt ¶
func (rr *RangedReader) ReadAt(buf []byte, offset int64) (n int, err error)
ReadAt reads from cachedReader if exists, otherwise fetches a new Resource first. Opens a resource and reads len(buf) bytes from offset into buf.
func (*RangedReader) SectionReader ¶
func (rr *RangedReader) SectionReader(ctx context.Context, offset, size int64) *Reader
SectionReader partitions a resource from `offset` with a specified `size`
func (*RangedReader) WithCachedReader ¶
func (rr *RangedReader) WithCachedReader(ctx context.Context, readFunc func())
WithCachedReader creates a Reader and saves it to the RangedReader instance. It takes a readFunc that will Seek the contents from Reader.
type Reader ¶
type Reader struct { // Resource to read from Resource *Resource // contains filtered or unexported fields }
Reader holds a Resource and specifies ranges to read from at a time. Implements the io.Reader, io.Seeker and io.Closer interfaces.