[#96] Support ranges for GetObject

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2021-06-24 14:10:00 +03:00
parent 39a43c21a1
commit c4fef3d948
4 changed files with 151 additions and 33 deletions

View file

@ -24,6 +24,7 @@ type (
getParams struct {
io.Writer
*object.Range
offset int64
length int64
@ -73,6 +74,13 @@ func (n *layer) objectGet(ctx context.Context, p *getParams) (*object.Object, er
return n.pool.GetObject(ctx, ops, n.BearerOpt(ctx))
}
// objectRange gets object range and writes it into provided io.Writer.
func (n *layer) objectRange(ctx context.Context, p *getParams) ([]byte, error) {
w := newWriter(p.Writer, p.offset, p.length)
ops := new(client.RangeDataParams).WithAddress(p.address).WithDataWriter(w).WithRange(p.Range)
return n.pool.ObjectPayloadRangeData(ctx, ops, n.BearerOpt(ctx))
}
// objectPut into NeoFS, took payload from io.Reader.
func (n *layer) objectPut(ctx context.Context, p *PutObjectParams) (*ObjectInfo, error) {
var (