owl-blogs/domain/model/binary_file.go

25 lines
366 B
Go

package model
import (
"mime"
"strings"
)
type BinaryFile struct {
Id string
Name string
Data []byte
}
func (b *BinaryFile) Mime() string {
parts := strings.Split(b.Name, ".")
if len(parts) < 2 {
return "application/octet-stream"
}
t := mime.TypeByExtension("." + parts[len(parts)-1])
if t == "" {
return "application/octet-stream"
}
return t
}