owl-blogs/domain/model/binary_file.go

25 lines
366 B
Go
Raw Normal View History

2023-07-08 09:08:55 +00:00
package model
2023-07-09 17:09:54 +00:00
import (
"mime"
"strings"
)
2023-07-08 09:08:55 +00:00
type BinaryFile struct {
Id string
Name string
Data []byte
}
2023-07-09 17:09:54 +00:00
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
}