File: create_mpu_checksum.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.24.1-2~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 554,032 kB
  • sloc: java: 15,941; makefile: 419; sh: 175
file content (36 lines) | stat: -rw-r--r-- 1,112 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package s3

import (
	"context"
	"fmt"

	internalcontext "github.com/aws/aws-sdk-go-v2/internal/context"
	"github.com/aws/smithy-go/middleware"
)

// backfills checksum algorithm onto the context for CreateMultipart upload so
// transfer manager can set a checksum header on the request accordingly for
// s3express requests
type setCreateMPUChecksumAlgorithm struct{}

func (*setCreateMPUChecksumAlgorithm) ID() string {
	return "setCreateMPUChecksumAlgorithm"
}

func (*setCreateMPUChecksumAlgorithm) HandleSerialize(
	ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler,
) (
	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
) {
	input, ok := in.Parameters.(*CreateMultipartUploadInput)
	if !ok {
		return out, metadata, fmt.Errorf("unexpected input type %T", in.Parameters)
	}

	ctx = internalcontext.SetChecksumInputAlgorithm(ctx, string(input.ChecksumAlgorithm))
	return next.HandleSerialize(ctx, in)
}

func addSetCreateMPUChecksumAlgorithm(s *middleware.Stack) error {
	return s.Serialize.Add(&setCreateMPUChecksumAlgorithm{}, middleware.Before)
}