// Hash returns the Md5sum of an object returning a lowercase hex string
Hash returns the Md5sum of an object returning a lowercase hex string
// Hash returns the Md5sum of an object returning a lowercase hex string
func (o *Object) Hash(t hash.Type) (string, error) {
	if t != hash.MD5 {
		return "", hash.ErrUnsupported
	}
	hash := strings.Trim(strings.ToLower(o.etag), `"`)
	if !matchMd5.MatchString(hash) {
		err := o.readMetaData()
		if err != nil {
			return "", err
		}
		if md5sum, ok := o.meta[metaMD5Hash]; ok {
			md5sumBytes, err := base64.StdEncoding.DecodeString(*md5sum)
			if err != nil {
				return "", err
			}
			hash = hex.EncodeToString(md5sumBytes)
		} else {
			hash = ""
		}
	}
	return hash, nil
}
func ( o * Object ) Hash ( t hash . Type ) ( string , error ) { if t != hash . MD5 { return " " , hash . ErrUnsupported } hash := strings . Trim ( strings . ToLower ( o . etag ) , `"` ) if ! matchMd5 . MatchString ( hash ) { err := o . readMetaData ( ) if err != nil { return " " , err } if md5sum , ok := o . meta [ metaMD5Hash ] ; ok { md5sumBytes , err := base64 . StdEncoding . DecodeString ( * md5sum ) if err != nil { return " " , err } hash = hex . EncodeToString ( md5sumBytes ) } else { hash = " " } } return hash , nil }
Hash returns the Md5sum of an object returning a lowercase hex string
Hash returns the Md5sum of an object returning a lowercase hex string
// Check the etag is a valid md5sum