From b020cd6652c8e84915ca14d77354aab27aa341c2 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 23 Apr 2021 15:28:58 +0300 Subject: [PATCH] uploader: fix passing attributes to object --- neofs/client-plant.go | 3 +++ uploader/upload.go | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/neofs/client-plant.go b/neofs/client-plant.go index e89fd25..2f7ed87 100644 --- a/neofs/client-plant.go +++ b/neofs/client-plant.go @@ -26,6 +26,7 @@ type BaseOptions struct { type PutOptions struct { BaseOptions + Attributes []*object.Attribute ContainerID *container.ID OwnerID *owner.ID PrepareObjectOnsite bool @@ -105,6 +106,7 @@ func (oc *neofsObjectClient) Put(ctx context.Context, options *PutOptions) (*obj rawObject := objectCore.NewRaw() rawObject.SetContainerID(options.ContainerID) rawObject.SetOwnerID(options.OwnerID) + rawObject.SetAttributes(options.Attributes...) ns := newNetworkState(ctx, options.Client) objectTarget := transformer.NewPayloadSizeLimiter(maxObjectSize, func() transformer.ObjectTarget { return transformer.NewFormatTarget(&transformer.FormatterParams{ @@ -137,6 +139,7 @@ func (oc *neofsObjectClient) Put(ctx context.Context, options *PutOptions) (*obj rawObject := object.NewRaw() rawObject.SetContainerID(options.ContainerID) rawObject.SetOwnerID(options.OwnerID) + rawObject.SetAttributes(options.Attributes...) ops := new(client.PutObjectParams). WithObject(rawObject.Object()). WithPayloadReader(options.Reader) diff --git a/uploader/upload.go b/uploader/upload.go index 2b10996..8cde2c2 100644 --- a/uploader/upload.go +++ b/uploader/upload.go @@ -98,11 +98,6 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) { attributes = append(attributes, timestamp) } oid, bt := u.fetchOwnerAndBearerToken(c) - // Prepare a new object and fill it. - raw := object.NewRaw() - raw.SetContainerID(cid) - raw.SetOwnerID(oid) - raw.SetAttributes(attributes...) putOpts := putOptionsPool.Get().(*neofs.PutOptions) defer putOptionsPool.Put(putOpts) // Try to put file into NeoFS or throw an error. @@ -112,6 +107,7 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) { c.Error("failed to get neofs connection artifacts", fasthttp.StatusInternalServerError) return } + putOpts.Attributes = attributes putOpts.BearerToken = bt putOpts.ContainerID = cid putOpts.OwnerID = oid