From 3c6deccbea58a39f010a4b562cffa39ae17e91b3 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Tue, 8 Aug 2017 16:18:44 -0400 Subject: [PATCH] types: webm must not have a mimetype yet? Signed-off-by: Vincent Batts --- types/types.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/types/types.go b/types/types.go index 0eefe8c..87c2099 100644 --- a/types/types.go +++ b/types/types.go @@ -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") }