File size: 789 Bytes
e43a4a9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | const AUDIO_MIME = {
mp3: "audio/mpeg",
wav: "audio/wav",
flac: "audio/flac",
opus: "audio/opus",
pcm16: "audio/L16"
};
const IMAGE_MIME = {
jpg: "image/jpeg",
jpeg: "image/jpeg",
png: "image/png",
webp: "image/webp",
gif: "image/gif"
};
export function audioMimeType(format) {
return AUDIO_MIME[format] ?? "application/octet-stream";
}
export function imageMimeType(format) {
return IMAGE_MIME[format] ?? "image/png";
}
export function extensionFromMimeType(mimeType) {
const mimeMap = {
"audio/mpeg": "mp3",
"audio/wav": "wav",
"audio/flac": "flac",
"audio/opus": "opus",
"audio/L16": "pcm16",
"image/jpeg": "jpg",
"image/png": "png",
"image/webp": "webp",
"image/gif": "gif"
};
return mimeMap[mimeType] ?? "bin";
}
|