Skip to content

Commit 92aabc2

Browse files
fix: broken unmarshal metadata map due to XML changes (#1698)
1 parent 3f1cfb7 commit 92aabc2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

api-datatypes.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,20 @@ type StringMap map[string]string
4545
// on the first line is initialize it.
4646
func (m *StringMap) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
4747
*m = StringMap{}
48-
type xmlMapEntry struct {
49-
XMLName xml.Name
50-
Value string `xml:",chardata"`
48+
type Item struct {
49+
Key string
50+
Value string
5151
}
5252
for {
53-
var e xmlMapEntry
53+
var e Item
5454
err := d.Decode(&e)
5555
if err == io.EOF {
5656
break
57-
} else if err != nil {
57+
}
58+
if err != nil {
5859
return err
5960
}
60-
(*m)[e.XMLName.Local] = e.Value
61+
(*m)[e.Key] = e.Value
6162
}
6263
return nil
6364
}
@@ -118,7 +119,7 @@ type ObjectInfo struct {
118119
Metadata http.Header `json:"metadata" xml:"-"`
119120

120121
// x-amz-meta-* headers stripped "x-amz-meta-" prefix containing the first value.
121-
UserMetadata StringMap `json:"userMetadata"`
122+
UserMetadata StringMap `json:"userMetadata,omitempty"`
122123

123124
// x-amz-tagging values in their k/v values.
124125
UserTags map[string]string `json:"userTags"`

0 commit comments

Comments
 (0)