mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-15 16:29:37 +00:00
Fix:Set correct mime type for m4b file static requests
This commit is contained in:
parent
6cbfd8679b
commit
976427b0b3
4 changed files with 24 additions and 13 deletions
|
|
@ -1,6 +1,6 @@
|
|||
const express = require('express')
|
||||
const Path = require('path')
|
||||
const Logger = require('../Logger')
|
||||
const { getAudioMimeTypeFromExtname } = require('../utils/fileUtils')
|
||||
|
||||
class StaticRouter {
|
||||
constructor(db) {
|
||||
|
|
@ -20,7 +20,16 @@ class StaticRouter {
|
|||
var fullPath = null
|
||||
if (item.isFile) fullPath = item.path
|
||||
else fullPath = Path.join(item.path, remainingPath)
|
||||
res.sendFile(fullPath)
|
||||
|
||||
var opts = {}
|
||||
|
||||
// Express does not set the correct mimetype for m4b files so use our defined mimetypes if available
|
||||
const audioMimeType = getAudioMimeTypeFromExtname(Path.extname(fullPath))
|
||||
if (audioMimeType) {
|
||||
opts = { headers: { 'Content-Type': audioMimeType } }
|
||||
}
|
||||
|
||||
res.sendFile(fullPath, opts)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue