diff --git a/pkg/local_object_storage/engine/get.go b/pkg/local_object_storage/engine/get.go index 56aa2cf9..8caf4302 100644 --- a/pkg/local_object_storage/engine/get.go +++ b/pkg/local_object_storage/engine/get.go @@ -97,3 +97,28 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) { obj: obj, }, nil } + +// Get reads object from local storage by provided address. +func Get(storage *StorageEngine, addr *objectSDK.Address) (*object.Object, error) { + res, err := storage.Get(new(GetPrm). + WithAddress(addr), + ) + if err != nil { + return nil, err + } + + return res.Object(), nil +} + +// GetRange reads object payload range from local storage by provided address. +func GetRange(storage *StorageEngine, addr *objectSDK.Address, rng *objectSDK.Range) ([]byte, error) { + res, err := storage.Get(new(GetPrm). + WithAddress(addr). + WithPayloadRange(rng.GetOffset(), rng.GetLength()), + ) + if err != nil { + return nil, err + } + + return res.Object().Payload(), nil +} diff --git a/pkg/local_object_storage/engine/head.go b/pkg/local_object_storage/engine/head.go index 153afe49..b4a3fbdf 100644 --- a/pkg/local_object_storage/engine/head.go +++ b/pkg/local_object_storage/engine/head.go @@ -73,3 +73,15 @@ func (e *StorageEngine) Head(prm *HeadPrm) (*HeadRes, error) { head: head, }, nil } + +// Head reads object header from local storage by provided address. +func Head(storage *StorageEngine, addr *objectSDK.Address) (*object.Object, error) { + res, err := storage.Head(new(HeadPrm). + WithAddress(addr), + ) + if err != nil { + return nil, err + } + + return res.Header(), nil +} diff --git a/pkg/local_object_storage/engine/put.go b/pkg/local_object_storage/engine/put.go index ff085a95..062b11a0 100644 --- a/pkg/local_object_storage/engine/put.go +++ b/pkg/local_object_storage/engine/put.go @@ -89,3 +89,12 @@ func (e *StorageEngine) objectExists(obj *object.Object, shards []*shard.Shard) return exists } + +// Put writes provided object to local storage. +func Put(storage *StorageEngine, obj *object.Object) error { + _, err := storage.Put(new(PutPrm). + WithObject(obj), + ) + + return err +} diff --git a/pkg/local_object_storage/engine/select.go b/pkg/local_object_storage/engine/select.go index e0925451..5ed46631 100644 --- a/pkg/local_object_storage/engine/select.go +++ b/pkg/local_object_storage/engine/select.go @@ -58,3 +58,20 @@ func (e *StorageEngine) Select(prm *SelectPrm) (*SelectRes, error) { addrList: addrList, }, nil } + +// Select selects objects from local storage using provided filters. +func Select(storage *StorageEngine, fs object.SearchFilters) ([]*object.Address, error) { + res, err := storage.Select(new(SelectPrm). + WithFilters(fs), + ) + if err != nil { + return nil, err + } + + return res.AddressList(), nil +} + +// SelectAll selects all objects from local storage. +func SelectAll(storage *StorageEngine) ([]*object.Address, error) { + return Select(storage, object.SearchFilters{}) +}