github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/depends/conf/filesystem/object_meta.go (about) 1 package filesystem 2 3 import ( 4 "strconv" 5 "strings" 6 ) 7 8 type ObjectMeta struct { 9 ObjectID uint64 `json:"objectID"` 10 Group string `json:"group"` 11 Size int64 `json:"size"` 12 ContentType string `json:"contentType"` 13 ETag string `json:"etag"` 14 } 15 16 func (meta ObjectMeta) Key() string { 17 return meta.Group + "/" + strconv.FormatUint(meta.ObjectID, 10) 18 } 19 20 func ParseObjectMetaFromKey(key string) (*ObjectMeta, error) { 21 parts := strings.Split(key, "/") 22 if len(parts) != 2 { 23 return nil, ErrInvalidObjectKey 24 } 25 grp := parts[0] 26 27 oid, err := strconv.ParseUint(parts[1], 10, 64) 28 if err != nil { 29 return nil, ErrInvalidObjectKey 30 } 31 32 om := &ObjectMeta{ObjectID: oid, Group: grp} 33 34 return om, nil 35 }