diff --git a/cmd/frostfs-cli/internal/client/client.go b/cmd/frostfs-cli/internal/client/client.go index 9807e111c..c73fb1a35 100644 --- a/cmd/frostfs-cli/internal/client/client.go +++ b/cmd/frostfs-cli/internal/client/client.go @@ -9,6 +9,7 @@ import ( "sort" "strings" + buffPool "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/pool" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/accounting" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/checksum" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client" @@ -356,6 +357,8 @@ type PutObjectPrm struct { headerCallback func(*objectSDK.Object) prepareLocally bool + + objSize uint64 } // SetHeader sets object header. @@ -363,6 +366,10 @@ func (x *PutObjectPrm) SetHeader(hdr *objectSDK.Object) { x.hdr = hdr } +func (x *PutObjectPrm) SetObjSize(size uint64) { + x.objSize = size +} + // SetPayloadReader sets reader of the object payload. func (x *PutObjectPrm) SetPayloadReader(rdr io.Reader) { x.rdr = rdr @@ -402,6 +409,11 @@ func (x *PutObjectPrm) convertToSDKPrm(ctx context.Context) (client.PrmObjectPut putPrm.MaxSize = res.Info().MaxObjectSize() putPrm.EpochSource = epochSource(res.Info().CurrentEpoch()) putPrm.WithoutHomomorphHash = res.Info().HomomorphicHashingDisabled() + + if x.objSize > 2*res.Info().MaxObjectSize() { + pool := buffPool.NewBufferPool(uint32(res.Info().MaxObjectSize())) + putPrm.Pool = &pool + } } else { putPrm.Session = x.sessionToken } diff --git a/cmd/frostfs-cli/modules/object/put.go b/cmd/frostfs-cli/modules/object/put.go index a41d3c0aa..8ddf66928 100644 --- a/cmd/frostfs-cli/modules/object/put.go +++ b/cmd/frostfs-cli/modules/object/put.go @@ -130,6 +130,11 @@ func putObject(cmd *cobra.Command, _ []string) { commonCmd.ExitOnErr(cmd, "can't parse object copies numbers information: %w", err) prm.SetCopiesNumberByVectors(parseCopyNumber(cmd, copyNum)) + fi, err := f.Stat() + if err == nil { + prm.SetObjSize(uint64(fi.Size())) + } + res, err := internalclient.PutObject(cmd.Context(), prm) if p != nil { p.Finish()