diff --git a/api-datatypes.go b/api-datatypes.go index cb811b4e9c..258be7cecb 100644 --- a/api-datatypes.go +++ b/api-datatypes.go @@ -43,14 +43,29 @@ type StringMap map[string]string // if m is nil it can be initialized, which is often the case if m is // nested in another xml structural. This is also why the first thing done // on the first line is initialize it. -func (m *StringMap) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error { +func (m *StringMap) UnmarshalXML(d *xml.Decoder, s xml.StartElement) error { *m = StringMap{} - type Item struct { - Key string - Value string - } for { - var e Item + // Fallback for value + if s.Name.Local == "UserMetadata" { + var e struct { + XMLName xml.Name + Value string `xml:",chardata"` + } + err := d.Decode(&e) + if err == io.EOF { + break + } + if err != nil { + return err + } + (*m)[e.XMLName.Local] = e.Value + continue + } + var e struct { + Key string + Value string + } err := d.Decode(&e) if err == io.EOF { break @@ -124,7 +139,7 @@ type ObjectInfo struct { UserMetadata StringMap `json:"userMetadata,omitempty"` // x-amz-tagging values in their k/v values. - UserTags map[string]string `json:"userTags"` + UserTags StringMap `json:"userTags" xml:"TagSet"` // x-amz-tagging-count value UserTagCount int