diff --git a/jetstream/object.go b/jetstream/object.go index a0eecff33..cef46c3e8 100644 --- a/jetstream/object.go +++ b/jetstream/object.go @@ -472,6 +472,7 @@ type ( err error ctx context.Context digest hash.Hash + cursor uint64 } ) @@ -1488,6 +1489,27 @@ func (o *objResult) Close() error { return o.r.Close() } +func (o *objResult) Seek(offset int64, whence int) (int64, error) { + o.Lock() + defer o.Unlock() + if o.r == nil { + return 0, io.EOF + } + + o.r.Read() + seeker, ok := o.r.(io.Seeker) + if !ok { + return 0, errors.New("underlying reader does not support seeking") + } + + newOffset, err := seeker.Seek(offset, whence) + if err != nil { + return 0, err + } + + return newOffset, nil +} + func (o *objResult) setErr(err error) { o.Lock() defer o.Unlock()