From a22edb29a5a1c974a10d994d050d6992434edfbd Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Fri, 23 Dec 2022 02:02:47 +0100 Subject: [PATCH] Videos: Assume "video/quicktime" mime type for .mov files #3008 Signed-off-by: Michael Mayer --- pkg/fs/mime.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/fs/mime.go b/pkg/fs/mime.go index 0a68af2c1..480f1f3da 100644 --- a/pkg/fs/mime.go +++ b/pkg/fs/mime.go @@ -18,6 +18,8 @@ const ( MimeTypeAVIF = "image/avif" MimeTypeHEIC = "image/heic" MimeTypeWebP = "image/webp" + MimeTypeMP4 = "video/mp4" + MimeTypeMOV = "video/quicktime" MimeTypeXML = "text/xml" MimeTypeJSON = "application/json" ) @@ -30,12 +32,16 @@ func init() { // MimeType returns the mime type of a file, or an empty string if it could not be detected. func MimeType(filename string) (mimeType string) { // Workaround, since "image/dng" cannot be recognized yet. - if ext := strings.ToLower(filepath.Ext(filename)); ext == "" { + if ext := Extensions[strings.ToLower(filepath.Ext(filename))]; ext == "" { // Continue. - } else if Extensions[ext] == ImageDNG { + } else if ext == ImageDNG { return MimeTypeDNG - } else if Extensions[ext] == ImageAVIF { + } else if ext == ImageAVIF { return MimeTypeAVIF + } else if ext == VideoMP4 { + return MimeTypeMP4 + } else if ext == VideoMOV { + return MimeTypeMOV } if t, err := mimetype.DetectFile(filename); err != nil {