forked from TrueCloudLab/frostfs-s3-gw
[#346] neofs: Fix ReadObject
implementation
`ReadObject` method must read full object payload into memory when `WithHeader` and `WithPayload` are set and write it into heading part. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
dc628aef22
commit
e559312fbf
1 changed files with 10 additions and 2 deletions
|
@ -420,9 +420,17 @@ func (x *NeoFS) ReadObject(ctx context.Context, prm layer.PrmObjectRead) (*layer
|
||||||
return nil, fmt.Errorf("init full object reading via connection pool: %w", err)
|
return nil, fmt.Errorf("init full object reading via connection pool: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer res.Payload.Close()
|
||||||
|
|
||||||
|
payload, err := io.ReadAll(res.Payload)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("read full object payload: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
object.NewRawFrom(&res.Header).SetPayload(payload)
|
||||||
|
|
||||||
return &layer.ObjectPart{
|
return &layer.ObjectPart{
|
||||||
Head: &res.Header,
|
Head: &res.Header,
|
||||||
Payload: res.Payload,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue