2020-09-21 14:31:31 +00:00
|
|
|
package putsvc
|
|
|
|
|
|
|
|
import (
|
|
|
|
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
|
|
|
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
|
2020-09-29 15:05:22 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
|
2020-09-21 14:31:31 +00:00
|
|
|
)
|
|
|
|
|
2021-05-27 14:25:29 +00:00
|
|
|
func (s *streamer) toInitPrm(part *objectV2.PutObjectPartInit, req *objectV2.PutRequest) (*putsvc.PutInitPrm, error) {
|
2020-09-21 14:31:31 +00:00
|
|
|
oV2 := new(objectV2.Object)
|
2020-09-29 15:05:22 +00:00
|
|
|
oV2.SetObjectID(part.GetObjectID())
|
|
|
|
oV2.SetSignature(part.GetSignature())
|
|
|
|
oV2.SetHeader(part.GetHeader())
|
2020-09-21 14:31:31 +00:00
|
|
|
|
2021-01-12 14:55:02 +00:00
|
|
|
commonPrm, err := util.CommonPrmFromV2(req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-09-21 14:31:31 +00:00
|
|
|
return new(putsvc.PutInitPrm).
|
|
|
|
WithObject(
|
|
|
|
object.NewRawFromV2(oV2),
|
|
|
|
).
|
2021-05-27 14:25:29 +00:00
|
|
|
WithRelay(s.relayRequest).
|
2021-01-12 14:55:02 +00:00
|
|
|
WithCommonPrm(commonPrm), nil
|
2020-09-21 14:31:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func toChunkPrm(req *objectV2.PutObjectPartChunk) *putsvc.PutChunkPrm {
|
|
|
|
return new(putsvc.PutChunkPrm).
|
|
|
|
WithChunk(req.GetChunk())
|
|
|
|
}
|
|
|
|
|
|
|
|
func fromPutResponse(r *putsvc.PutResponse) *objectV2.PutResponse {
|
|
|
|
body := new(objectV2.PutResponseBody)
|
|
|
|
body.SetObjectID(r.ObjectID().ToV2())
|
|
|
|
|
|
|
|
resp := new(objectV2.PutResponse)
|
|
|
|
resp.SetBody(body)
|
|
|
|
|
|
|
|
return resp
|
|
|
|
}
|