Get contentType for Flex FileReference upload?

Posted on 2009-12-22
Last Modified: 2013-11-11
Hi there,

I'm trying to make an image upload in flex, which, once uploaded, is sent to Amazon S3.
But, I need to know the MIME content type of the file.

For PCs, I can just check the file extension, but what about Macs? I know it's an image, but I don't know if it is gif, jpeg, etc.

I can't get Flex (on the client side) to determine the content type of the file reference. How can I do this?

I've seen this:
But again it relies on filename extensions, not available on Mac, I tihnk. (I don't have one.)
Question by:the_cyman
    LVL 11

    Assisted Solution


    I just have knowledge of reading as I don't use a mac.

    Did you tried "extension" property for FileReference?

    The filename extension.

    from definition of extension      property

    A file's extension is the part of the name following (and not including) the final dot ("."). If there is no dot in the filename, the extension is null.

    Note: You should use the extension property to determine a file's type; do not use the creator or type properties. You should consider the creator and type properties to be considered deprecated. They apply to older versions of Mac OS.

    If this is not working may be you can try creator too I feel

    Accepted Solution

    Hi there,

    That works, but only for Adobe desktop apps in AIR.

    But, I found this code, I couldn't get it working properly, but there's a live sample. In the end, I just checked the first 3 bytes of the files on the webserver end to determine the image type, since those first three bytes are header data that describes the file type.

    Code to verify in content type in flex:

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
    The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
    In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
    The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now