internal

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checksum

type Checksum interface {
	hash.Hash

	// SumPutObject modifies the given [s3.PutObjectInput] with the appropriate checksum algorithm and value.
	//
	// Returns the same [s3.PutObjectInput].
	SumPutObject(*s3.PutObjectInput) *s3.PutObjectInput

	// SumCompleteMultipartUpload modifies the given [s3.CompleteMultipartUploadInput] with the appropriate checksum
	// algorithm, type, and value.
	//
	// If CreateMultipartUpload uses a checksum algorithm that does not support FULL_OBJECT type (e.g. SHA-1,
	// SHA-256), this method will no-op.
	//
	// Returns the same [s3.CompleteMultipartUploadInput].
	SumCompleteMultipartUpload(*s3.CompleteMultipartUploadInput) *s3.CompleteMultipartUploadInput

	// HashUploadPart modifies the given [s3.HashUploadPart] with the appropriate checksum algorith, type, and
	// value.
	//
	// If CreateMultipartUpload uses a checksum algorithm that does not support COMPOSITE type (e.g. CRC-64/NVME),
	// this method will no-op.
	//
	// Returns the same [s3.UploadPartInput].
	HashUploadPart([]byte, *s3.UploadPartInput) *s3.UploadPartInput
}

Checksum extends hash.Hash to add checksums to S3 operations.

For PutObject, Checksum can be used as a normal hash.Hash. When all data have been hashed, call SumPutObject to modify the s3.PutObjectInput with the expected algorithm and checksum.

For multipart upload, Checksum must be used at two places. First, it must be used as a normal hash.Hash passing the entire file, using SumCompleteMultipartUpload at the end. Secondly, for every UploadPart, HashUploadPart must be called to compute the hash for the specific part.

func NewFromCreateMultipartUpload

func NewFromCreateMultipartUpload(input *s3.CreateMultipartUploadInput) Checksum

NewFromCreateMultipartUpload is a variant of NewOrDefault that will modify the input parameters with default if necessary.

func NewFromPutObject

func NewFromPutObject(input *s3.PutObjectInput) Checksum

NewFromPutObject is a variant of NewOrDefault that will modify the input parameters with default if necessary.

func NewOrDefault

func NewOrDefault(checksumAlgorithm types.ChecksumAlgorithm, checksumType types.ChecksumType) (Checksum, types.ChecksumAlgorithm, types.ChecksumType)

NewOrDefault returns a new HashS3 from the specified checksum algorithm and type.

If there is no checksum algorithm (empty string), returns the recommended hash and checksum algorithm to be used. This is because according to https://github.com/nguyengg/xy3/issues/1, if there is no checksum algorithm specified to a CreateMultipartUpload request, the CompleteMultipartUpload will ultimately fail so New at the moment will recommend a default combination that work.

Caller should set the returned checksum algorithm and type to the s3.CreateMultipartUploadInput or s3.PutObjectInput accordingly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL