2020-09-21 14:31:31 +00:00
|
|
|
package putsvc
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
|
|
|
|
refsV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
|
|
|
putsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/put"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
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(
|
2022-03-03 14:19:05 +00:00
|
|
|
object.NewFromV2(oV2),
|
2020-09-21 14:31:31 +00:00
|
|
|
).
|
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 {
|
2022-05-12 16:37:46 +00:00
|
|
|
var idV2 refsV2.ObjectID
|
|
|
|
r.ObjectID().WriteToV2(&idV2)
|
|
|
|
|
2020-09-21 14:31:31 +00:00
|
|
|
body := new(objectV2.PutResponseBody)
|
2022-05-12 16:37:46 +00:00
|
|
|
body.SetObjectID(&idV2)
|
2020-09-21 14:31:31 +00:00
|
|
|
|
|
|
|
resp := new(objectV2.PutResponse)
|
|
|
|
resp.SetBody(body)
|
|
|
|
|
|
|
|
return resp
|
|
|
|
}
|