Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jon 17 posts 40 karma points
    Sep 21, 2010 @ 18:42
    Jon
    0

    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

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Sep 21, 2010 @ 20:57
    Lee Kelleher
    0

    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.

  • Jon 17 posts 40 karma points
    Sep 22, 2010 @ 10:42
    Jon
    1

    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

Please Sign in or register to post replies

Write your reply to:

Draft