mirror of
https://github.com/minio/minio.git
synced 2025-11-09 13:39:46 -05:00
Return InvalidDigest when md5 sent by client is invalid (#5654)
This is to ensure proper compatibility with AWS S3, handle special cases where - Content-Md5 is set to empty - Content-Md5 is set to invalid
This commit is contained in:
committed by
Dee Koder
parent
9ede179a21
commit
3145462ad2
11
cmd/utils.go
11
cmd/utils.go
@@ -102,8 +102,15 @@ func xmlDecoder(body io.Reader, v interface{}, size int64) error {
|
||||
}
|
||||
|
||||
// checkValidMD5 - verify if valid md5, returns md5 in bytes.
|
||||
func checkValidMD5(md5 string) ([]byte, error) {
|
||||
return base64.StdEncoding.DecodeString(strings.TrimSpace(md5))
|
||||
func checkValidMD5(h http.Header) ([]byte, error) {
|
||||
md5B64, ok := h["Content-Md5"]
|
||||
if ok {
|
||||
if md5B64[0] == "" {
|
||||
return nil, fmt.Errorf("Content-Md5 header set to empty value")
|
||||
}
|
||||
return base64.StdEncoding.DecodeString(md5B64[0])
|
||||
}
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
/// http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadingObjects.html
|
||||
|
||||
Reference in New Issue
Block a user