Videos: Assume "video/quicktime" mime type for .mov files #3008

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2022-12-23 02:02:47 +01:00
parent cab5efba36
commit a22edb29a5

View file

@ -18,6 +18,8 @@ const (
MimeTypeAVIF = "image/avif" MimeTypeAVIF = "image/avif"
MimeTypeHEIC = "image/heic" MimeTypeHEIC = "image/heic"
MimeTypeWebP = "image/webp" MimeTypeWebP = "image/webp"
MimeTypeMP4 = "video/mp4"
MimeTypeMOV = "video/quicktime"
MimeTypeXML = "text/xml" MimeTypeXML = "text/xml"
MimeTypeJSON = "application/json" 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. // MimeType returns the mime type of a file, or an empty string if it could not be detected.
func MimeType(filename string) (mimeType string) { func MimeType(filename string) (mimeType string) {
// Workaround, since "image/dng" cannot be recognized yet. // 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. // Continue.
} else if Extensions[ext] == ImageDNG { } else if ext == ImageDNG {
return MimeTypeDNG return MimeTypeDNG
} else if Extensions[ext] == ImageAVIF { } else if ext == ImageAVIF {
return MimeTypeAVIF return MimeTypeAVIF
} else if ext == VideoMP4 {
return MimeTypeMP4
} else if ext == VideoMOV {
return MimeTypeMOV
} }
if t, err := mimetype.DetectFile(filename); err != nil { if t, err := mimetype.DetectFile(filename); err != nil {