private string GetMediaType(string item)
{
switch (Path.GetExtension(item).Substring(1))
{
case "xml": // Review
case "xhtml":
return "application/xhtml+xml";
case "jpg":
case "jpeg":
return "image/jpeg";
case "png":
return "image/png";
case "css":
return "text/css";
case "woff":
return "application/font-woff"; // http://stackoverflow.com/questions/2871655/proper-mime-type-for-fonts
case "ttf":
case "otf":
// According to http://stackoverflow.com/questions/2871655/proper-mime-type-for-fonts, the proper
// mime type for ttf fonts is now application/font-sfnt. However, this fails the Pagina Epubcheck
// for epub 3.0.1, since the proper mime type for ttf was not put into the epub standard until 3.1.
// See https://github.com/idpf/epub-revision/issues/443 and http://www.idpf.org/epub/31/spec/epub-changes.html#sec-epub31-cmt.
// Since there are no plans to deprecate application/vnd.ms-opentype and it's unlikely to break
// any reader (unlikely the reader even uses the type field), we're just sticking with that.
return "application/vnd.ms-opentype"; // http://stackoverflow.com/questions/2871655/proper-mime-type-for-fonts
case "smil":
return "application/smil+xml";
case "mp4":
return "audio/mp4";
case "mp3":
return "audio/mpeg";
}
throw new ApplicationException("unexpected file type in file " + item);
}