2020-09-21 14:31:31 +00:00
|
|
|
package putsvc
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
putsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/put"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
2024-11-07 14:32:10 +00:00
|
|
|
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/object"
|
|
|
|
refsV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs"
|
2023-07-06 12:36:41 +00:00
|
|
|
objectSDK "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(
|
2023-07-06 12:36:41 +00:00
|
|
|
objectSDK.NewFromV2(oV2),
|
2020-09-21 14:31:31 +00:00
|
|
|
).
|
2021-05-27 14:25:29 +00:00
|
|
|
WithRelay(s.relayRequest).
|
2023-04-11 18:01:00 +00:00
|
|
|
WithCommonPrm(commonPrm).
|
|
|
|
WithCopyNumbers(part.GetCopiesNumber()), 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
|
|
|
|
}
|