Mime Service problem on Album Art

Apparently the nsIMIMEService doesn’t work as I expected. I use it to determine the extension for the artwork file we create when reading the meta data image from a media file. Using the following code you should be able to get the extension from valid mime types:
// grab the extension from the mimetype
var mimeService = Cc["@mozilla.org/mime;1"]
.getService(Ci.nsIMIMEService);
var mimeInfo = mimeService.getFromTypeAndExtension(aMimeType, “”);
if (mimeInfo.getFileExtensions().hasMore()) {
ext = mimeInfo.primaryExtension;
}

Using a mime type of “image/jpg” however does not seem to return a valid extension? So we are going to do a small work around that will parse the aMimeType to try and get an extension out of it if the nsIMIMEService fails. And of course we are going to check that we get only valid image extensions (no exe or bat ones please).

~ by stevobird on August 21, 2008.

One Response to “Mime Service problem on Album Art”

  1. [...] – Mime Service problem on Album Art saved by spongebobfan6652008-10-08 – Why not just turn out the lights and hope for the best? saved [...]

Leave a Reply