mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
f781cce500
* GetObjectTagging * PutObjectTagging * DeleteObjectTagging
39 lines
648 B
Go
39 lines
648 B
Go
package s3api
|
|
|
|
import (
|
|
"encoding/xml"
|
|
)
|
|
|
|
type Tag struct {
|
|
Key string `xml:"Key"`
|
|
Value string `xml:"Value"`
|
|
}
|
|
|
|
type TagSet struct {
|
|
Tag []Tag `xml:"Tag"`
|
|
}
|
|
|
|
type Tagging struct {
|
|
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ Tagging"`
|
|
TagSet TagSet `xml:"TagSet"`
|
|
}
|
|
|
|
func (t *Tagging) ToTags() map[string]string {
|
|
output := make(map[string]string)
|
|
for _, tag := range t.TagSet.Tag {
|
|
output[tag.Key] = tag.Value
|
|
}
|
|
return output
|
|
}
|
|
|
|
func FromTags(tags map[string]string) (t *Tagging) {
|
|
t = &Tagging{}
|
|
for k, v := range tags {
|
|
t.TagSet.Tag = append(t.TagSet.Tag, Tag{
|
|
Key: k,
|
|
Value: v,
|
|
})
|
|
}
|
|
return
|
|
}
|