forked from TrueCloudLab/frostfs-http-gw
uploader: fix passing attributes to object
This commit is contained in:
parent
ed27e28a30
commit
b020cd6652
2 changed files with 4 additions and 5 deletions
|
@ -26,6 +26,7 @@ type BaseOptions struct {
|
||||||
|
|
||||||
type PutOptions struct {
|
type PutOptions struct {
|
||||||
BaseOptions
|
BaseOptions
|
||||||
|
Attributes []*object.Attribute
|
||||||
ContainerID *container.ID
|
ContainerID *container.ID
|
||||||
OwnerID *owner.ID
|
OwnerID *owner.ID
|
||||||
PrepareObjectOnsite bool
|
PrepareObjectOnsite bool
|
||||||
|
@ -105,6 +106,7 @@ func (oc *neofsObjectClient) Put(ctx context.Context, options *PutOptions) (*obj
|
||||||
rawObject := objectCore.NewRaw()
|
rawObject := objectCore.NewRaw()
|
||||||
rawObject.SetContainerID(options.ContainerID)
|
rawObject.SetContainerID(options.ContainerID)
|
||||||
rawObject.SetOwnerID(options.OwnerID)
|
rawObject.SetOwnerID(options.OwnerID)
|
||||||
|
rawObject.SetAttributes(options.Attributes...)
|
||||||
ns := newNetworkState(ctx, options.Client)
|
ns := newNetworkState(ctx, options.Client)
|
||||||
objectTarget := transformer.NewPayloadSizeLimiter(maxObjectSize, func() transformer.ObjectTarget {
|
objectTarget := transformer.NewPayloadSizeLimiter(maxObjectSize, func() transformer.ObjectTarget {
|
||||||
return transformer.NewFormatTarget(&transformer.FormatterParams{
|
return transformer.NewFormatTarget(&transformer.FormatterParams{
|
||||||
|
@ -137,6 +139,7 @@ func (oc *neofsObjectClient) Put(ctx context.Context, options *PutOptions) (*obj
|
||||||
rawObject := object.NewRaw()
|
rawObject := object.NewRaw()
|
||||||
rawObject.SetContainerID(options.ContainerID)
|
rawObject.SetContainerID(options.ContainerID)
|
||||||
rawObject.SetOwnerID(options.OwnerID)
|
rawObject.SetOwnerID(options.OwnerID)
|
||||||
|
rawObject.SetAttributes(options.Attributes...)
|
||||||
ops := new(client.PutObjectParams).
|
ops := new(client.PutObjectParams).
|
||||||
WithObject(rawObject.Object()).
|
WithObject(rawObject.Object()).
|
||||||
WithPayloadReader(options.Reader)
|
WithPayloadReader(options.Reader)
|
||||||
|
|
|
@ -98,11 +98,6 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) {
|
||||||
attributes = append(attributes, timestamp)
|
attributes = append(attributes, timestamp)
|
||||||
}
|
}
|
||||||
oid, bt := u.fetchOwnerAndBearerToken(c)
|
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)
|
putOpts := putOptionsPool.Get().(*neofs.PutOptions)
|
||||||
defer putOptionsPool.Put(putOpts)
|
defer putOptionsPool.Put(putOpts)
|
||||||
// Try to put file into NeoFS or throw an error.
|
// 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)
|
c.Error("failed to get neofs connection artifacts", fasthttp.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
putOpts.Attributes = attributes
|
||||||
putOpts.BearerToken = bt
|
putOpts.BearerToken = bt
|
||||||
putOpts.ContainerID = cid
|
putOpts.ContainerID = cid
|
||||||
putOpts.OwnerID = oid
|
putOpts.OwnerID = oid
|
||||||
|
|
Loading…
Reference in a new issue