types: webm must not have a mimetype yet?

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2017-08-08 16:18:44 -04:00
parent 4a23b6bac1
commit 3c6deccbea
Signed by: vbatts
GPG Key ID: 10937E57733F1362
1 changed files with 7 additions and 4 deletions

View File

@ -25,7 +25,13 @@ type File struct {
// ContentType guesses the mime-type by the file's extension
func (f *File) ContentType() string {
return mime.TypeByExtension(filepath.Ext(f.Filename))
mtype := mime.TypeByExtension(filepath.Ext(f.Filename))
if mtype == "" {
if strings.HasSuffix(f.Filename, ".webm") {
return "video/webm; charset=binary"
}
}
return mtype
}
func (f *File) IsImage() bool {
@ -33,9 +39,6 @@ func (f *File) IsImage() bool {
}
func (f *File) IsVideo() bool {
if strings.HasSuffix(f.Filename, ".webm") {
return true
}
return strings.HasPrefix(f.ContentType(), "video")
}