From 85c29e36299c6b535a598a30848a2118a2cd8d13 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 1 Sep 2023 15:12:44 +0100 Subject: [PATCH] serve dlna: fix MIME type if backend can't identify it If the server returns the MIME type as application/octet-stream we assume it doesn't really know what the MIME type. This patch tries matching the MIME type from the file extension instead in this case. This enables the use of servers (like OneDrive for Business) which don't allow the setting of MIME types on upload and have a poor selection of mime types. Fixes #7259 --- cmd/serve/dlna/cds.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/serve/dlna/cds.go b/cmd/serve/dlna/cds.go index f7cd77d1f..72fcceeab 100644 --- a/cmd/serve/dlna/cds.go +++ b/cmd/serve/dlna/cds.go @@ -60,6 +60,11 @@ func (cds *contentDirectoryService) cdsObjectToUpnpavObject(cdsObject object, fi var mimeType string if o, ok := fileInfo.DirEntry().(fs.Object); ok { mimeType = fs.MimeType(context.TODO(), o) + // If backend doesn't know what the mime type is then + // try getting it from the file name + if mimeType == "application/octet-stream" { + mimeType = fs.MimeTypeFromName(fileInfo.Name()) + } } else { mimeType = fs.MimeTypeFromName(fileInfo.Name()) }