[#472] blobstor: allow to put raw objects

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-04-19 13:00:56 +03:00 committed by Alex Vanin
parent 4a1ca4ecc1
commit 96a8ee7c83

View file

@ -1,6 +1,7 @@
package blobstor
import (
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/pkg/errors"
)
@ -29,6 +30,11 @@ func (b *BlobStor) Put(prm *PutPrm) (*PutRes, error) {
return nil, errors.Wrap(err, "could not marshal the object")
}
return b.PutRaw(prm.obj.Address(), data)
}
// PutRaw saves already marshaled object in BLOB storage.
func (b *BlobStor) PutRaw(addr *objectSDK.Address, data []byte) (*PutRes, error) {
big := b.isBig(data)
// compress object data
@ -36,11 +42,11 @@ func (b *BlobStor) Put(prm *PutPrm) (*PutRes, error) {
if big {
// save object in shallow dir
return new(PutRes), b.fsTree.Put(prm.obj.Address(), data)
return new(PutRes), b.fsTree.Put(addr, data)
}
// save object in blobovnicza
res, err := b.blobovniczas.put(prm.obj.Address(), data)
res, err := b.blobovniczas.put(addr, data)
if err != nil {
return nil, err
}