23 lines
555 B
TypeScript
23 lines
555 B
TypeScript
export function audioContentTypeForPath(filePath: string): string {
|
|
const lower = filePath.toLowerCase()
|
|
if (lower.endsWith(".mp3")) {
|
|
return "audio/mpeg"
|
|
}
|
|
if (lower.endsWith(".m4a") || lower.endsWith(".mp4")) {
|
|
return "audio/mp4"
|
|
}
|
|
if (lower.endsWith(".flac")) {
|
|
return "audio/flac"
|
|
}
|
|
if (lower.endsWith(".ogg") || lower.endsWith(".opus")) {
|
|
return "audio/ogg"
|
|
}
|
|
if (lower.endsWith(".wav")) {
|
|
return "audio/wav"
|
|
}
|
|
if (lower.endsWith(".aac")) {
|
|
return "audio/aac"
|
|
}
|
|
return "application/octet-stream"
|
|
}
|