Hi all. Really quick question. Is there any way within Umbraco to determine the MIME type of an item in the media folder via the API or otherwise? I have some files in the media folder and I can retrieve the extension, but translating this into a MIME type is proving harder than expected.
I'm aware I can do it within .net by accessing the registry (see here) but that only works if the server has the applications installed which register those MIME types (e.g. MS Word etc.).
My fallback will be to create a big old list of possible MIME types and corresponding extensions and do a lookup, but I wondered if there was any clever way to do it in Umbraco before I go ahead.
When you upload a file to the media section - using the File or Image media-types, there is a property called "umbracoExtension" ... that doesn't get the MIME-type, but just the file's extension, as you'd expect.
Which MIME-types / file-extensions are you having trouble with?
I found a couple of results via Google, which might be helpful?
Hi Lee, thanks for the reply! Yep I got the extension like you mentioned but it was transforming that into a MIME type that was giving me grief. Out of those 2 links you posted, the first one is the route I think I'll end up going down i.e. creating a big list of types in XML and doing a lookup. If I get anything useful I'll post back here in case anyone else needs it.
Get Media Item MIME Type
Hi all. Really quick question. Is there any way within Umbraco to determine the MIME type of an item in the media folder via the API or otherwise? I have some files in the media folder and I can retrieve the extension, but translating this into a MIME type is proving harder than expected.
I'm aware I can do it within .net by accessing the registry (see here) but that only works if the server has the applications installed which register those MIME types (e.g. MS Word etc.).
My fallback will be to create a big old list of possible MIME types and corresponding extensions and do a lookup, but I wondered if there was any clever way to do it in Umbraco before I go ahead.
Thanks!
Jon
Hi Jon,
When you upload a file to the media section - using the File or Image media-types, there is a property called "umbracoExtension" ... that doesn't get the MIME-type, but just the file's extension, as you'd expect.
Which MIME-types / file-extensions are you having trouble with?
I found a couple of results via Google, which might be helpful?
http://netomatix.com/Products/DocumentManagement/MimeDetector.aspx
http://stackoverflow.com/questions/58510/using-net-how-can-you-find-the-mime-type-of-a-file-based-on-the-file-signature
Cheers, Lee.
Hi Lee, thanks for the reply! Yep I got the extension like you mentioned but it was transforming that into a MIME type that was giving me grief. Out of those 2 links you posted, the first one is the route I think I'll end up going down i.e. creating a big list of types in XML and doing a lookup. If I get anything useful I'll post back here in case anyone else needs it.
Cheers,
Jon
is working on a reply...