[#472] blobstor: allow to put raw objects
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
4a1ca4ecc1
commit
96a8ee7c83
1 changed files with 8 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
package blobstor
|
package blobstor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/pkg/errors"
|
"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 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)
|
big := b.isBig(data)
|
||||||
|
|
||||||
// compress object data
|
// compress object data
|
||||||
|
@ -36,11 +42,11 @@ func (b *BlobStor) Put(prm *PutPrm) (*PutRes, error) {
|
||||||
|
|
||||||
if big {
|
if big {
|
||||||
// save object in shallow dir
|
// 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
|
// save object in blobovnicza
|
||||||
res, err := b.blobovniczas.put(prm.obj.Address(), data)
|
res, err := b.blobovniczas.put(addr, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue