diff --git a/api/layer/object.go b/api/layer/object.go index 5fad1d14d..551380ee2 100644 --- a/api/layer/object.go +++ b/api/layer/object.go @@ -189,17 +189,15 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Object prm.Attributes = append(prm.Attributes, [2]string{k, v}) } - n.prepareAuthParameters(ctx, &prm.PrmAuth) - if p.Header[VersionsDeleteMarkAttr] == DelMarkFullObject { if last := versions.getLast(); last != nil { n.objCache.Delete(last.Address()) } } - id, err := n.neoFS.CreateObject(ctx, prm) + id, err := n.objectPut(ctx, prm) if err != nil { - return nil, n.transformNeofsError(ctx, err) + return nil, err } if p.Lock != nil { @@ -451,6 +449,14 @@ func (n *layer) objectDelete(ctx context.Context, idCnr *cid.ID, idObj *oid.ID) return n.transformNeofsError(ctx, n.neoFS.DeleteObject(ctx, prm)) } +// objectPut prepare auth parameters and invoke neofs.CreateObject. +func (n *layer) objectPut(ctx context.Context, prm neofs.PrmObjectCreate) (*oid.ID, error) { + n.prepareAuthParameters(ctx, &prm.PrmAuth) + + id, err := n.neoFS.CreateObject(ctx, prm) + return id, n.transformNeofsError(ctx, err) +} + // ListObjectsV1 returns objects in a bucket for requests of Version 1. func (n *layer) ListObjectsV1(ctx context.Context, p *ListObjectsParamsV1) (*ListObjectsInfoV1, error) { var ( diff --git a/api/layer/system_object.go b/api/layer/system_object.go index 0008955c5..3df983178 100644 --- a/api/layer/system_object.go +++ b/api/layer/system_object.go @@ -117,9 +117,9 @@ func (n *layer) putSystemObjectIntoNeoFS(ctx context.Context, p *PutSystemObject prm.Attributes = append(prm.Attributes, [2]string{k, v}) } - id, err := n.neoFS.CreateObject(ctx, prm) + id, err := n.objectPut(ctx, prm) if err != nil { - return nil, n.transformNeofsError(ctx, err) + return nil, err } meta, err := n.objectHead(ctx, p.BktInfo.CID, id)