Add PostObject Checksum (#17244)

This commit is contained in:
Klaus Post
2023-05-23 07:58:33 -07:00
committed by GitHub
parent ef54200db7
commit 5677f73794
4 changed files with 54 additions and 11 deletions
+11 -1
View File
@@ -170,7 +170,7 @@ func (r *Reader) SetExpectedMax(expectedMax int64) {
// https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html
// Returns ErrInvalidChecksum if a problem with the checksum is found.
func (r *Reader) AddChecksum(req *http.Request, ignoreValue bool) error {
cs, err := GetContentChecksum(req)
cs, err := GetContentChecksum(req.Header)
if err != nil {
return ErrInvalidChecksum
}
@@ -181,6 +181,16 @@ func (r *Reader) AddChecksum(req *http.Request, ignoreValue bool) error {
if cs.Type.Trailing() {
r.trailer = req.Trailer
}
return r.AddNonTrailingChecksum(cs, ignoreValue)
}
// AddNonTrailingChecksum will add a checksum to the reader.
// The checksum cannot be trailing.
func (r *Reader) AddNonTrailingChecksum(cs *Checksum, ignoreValue bool) error {
if cs == nil {
return nil
}
r.contentHash = *cs
if ignoreValue {
// Do not validate, but allow for transfer
return nil