2022-03-01 19:02:24 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
2022-03-04 13:07:27 +00:00
|
|
|
layer "github.com/nspcc-dev/neofs-s3-gw/api/layer/neofs"
|
2022-03-01 19:02:24 +00:00
|
|
|
"github.com/nspcc-dev/neofs-s3-gw/internal/neofs"
|
|
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
|
|
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
|
|
|
)
|
|
|
|
|
|
|
|
// mediator which implements layer.NeoFS through neofs.NeoFS.
|
|
|
|
type layerNeoFS struct {
|
|
|
|
*neofs.NeoFS
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *layerNeoFS) CreateContainer(ctx context.Context, prm layer.PrmContainerCreate) (*cid.ID, error) {
|
|
|
|
return x.NeoFS.CreateContainer(ctx, neofs.PrmContainerCreate{
|
2022-03-04 13:07:27 +00:00
|
|
|
Creator: prm.Creator,
|
|
|
|
Policy: prm.Policy,
|
|
|
|
Name: prm.Name,
|
|
|
|
Time: prm.Time,
|
|
|
|
BasicACL: prm.BasicACL,
|
|
|
|
SessionToken: prm.SessionToken,
|
|
|
|
AdditionalAttributes: prm.AdditionalAttributes,
|
2022-03-01 19:02:24 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *layerNeoFS) CreateObject(ctx context.Context, prm layer.PrmObjectCreate) (*oid.ID, error) {
|
|
|
|
return x.NeoFS.CreateObject(ctx, neofs.PrmObjectCreate{
|
|
|
|
Creator: prm.Creator,
|
|
|
|
Container: prm.Container,
|
|
|
|
Time: time.Now().UTC(),
|
|
|
|
Filename: prm.Filename,
|
|
|
|
PayloadSize: prm.PayloadSize,
|
|
|
|
Attributes: prm.Attributes,
|
|
|
|
Payload: prm.Payload,
|
|
|
|
BearerToken: prm.BearerToken,
|
|
|
|
PrivateKey: prm.PrivateKey,
|
2022-03-04 14:36:30 +00:00
|
|
|
Locks: prm.Locks,
|
2022-03-01 19:02:24 +00:00
|
|
|
})
|
|
|
|
}
|