[#1185] neofs-cli: Add progress bar to object put/get

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-03-09 13:35:52 +03:00 committed by Alex Vanin
parent c3db12d71b
commit ad4583fe85
4 changed files with 65 additions and 2 deletions

View file

@ -464,6 +464,13 @@ type GetObjectPrm struct {
objectAddressPrm
rawPrm
payloadWriterPrm
headerCallback func(*object.Object)
}
// SetHeaderCallback sets callback which is called on the object after the header is received,
// but before the payload is written.
func (p *GetObjectPrm) SetHeaderCallback(f func(*object.Object)) {
p.headerCallback = f
}
// GetObjectRes groups resulting values of GetObject operation.
@ -527,6 +534,9 @@ func GetObject(prm GetObjectPrm) (*GetObjectRes, error) {
_, err = rdr.Close()
return nil, fmt.Errorf("read object header: %w", err)
}
if prm.headerCallback != nil {
prm.headerCallback(&hdr)
}
sz := hdr.PayloadSize()
if sz > maxPayloadBufferSize {