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
This commit is contained in:
parent
b7ec75aab6
commit
85c29e3629
1 changed files with 5 additions and 0 deletions
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue