MCPcopy
hub / github.com/rclone/rclone / setObjectRetention

Method setObjectRetention

backend/s3/s3.go:5114–5136  ·  view source on GitHub ↗

setObjectRetention sets Object Lock retention on an object via PutObjectRetention API Note: We use smithyhttp.AddContentChecksumMiddleware to ensure Content-MD5 is calculated for the request body. The AWS SDK v2 switched from MD5 to CRC32 as the default checksum algorithm, but some S3-compatible pr

(ctx context.Context, mode types.ObjectLockRetentionMode, retainUntilDate time.Time)

Source from the content-addressed store, hash-verified

5112// still require Content-MD5 for PutObjectRetention requests.
5113// See: https://github.com/aws/aws-sdk-go-v2/discussions/2960
5114func (o *Object) setObjectRetention(ctx context.Context, mode types.ObjectLockRetentionMode, retainUntilDate time.Time) error {
5115 bucket, bucketPath := o.split()
5116 req := s3.PutObjectRetentionInput{
5117 Bucket: &bucket,
5118 Key: &bucketPath,
5119 VersionId: o.versionID,
5120 Retention: &types.ObjectLockRetention{
5121 Mode: mode,
5122 RetainUntilDate: &retainUntilDate,
5123 },
5124 }
5125 if o.fs.opt.RequesterPays {
5126 req.RequestPayer = types.RequestPayerRequester
5127 }
5128 if o.fs.opt.BypassGovernanceRetention {
5129 req.BypassGovernanceRetention = &o.fs.opt.BypassGovernanceRetention
5130 }
5131 return o.fs.pacer.Call(func() (bool, error) {
5132 _, err := o.fs.c.PutObjectRetention(ctx, &req,
5133 s3.WithAPIOptions(smithyhttp.AddContentChecksumMiddleware))
5134 return o.fs.shouldRetry(ctx, err)
5135 })
5136}
5137
5138// setObjectLegalHold sets Object Lock legal hold on an object via PutObjectLegalHold API
5139//

Callers 1

Calls 3

splitMethod · 0.95
CallMethod · 0.45
shouldRetryMethod · 0.45

Tested by

no test coverage detected