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).

[...] – Mime Service problem on Album Art saved by spongebobfan6652008-10-08 – Why not just turn out the lights and hope for the best? saved [...]
Websites tagged "mime" on Postsaver said this on October 12, 2008 at 11:48 am |