Get contentType for Flex FileReference upload?

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:
http://groups.google.com/group/flex_india/browse_thread/thread/881dbc640cbafc46
But again it relies on filename extensions, not available on Mac, I tihnk. (I don't have one.)
the_cymanAsked:
Who is Participating?
 
the_cymanConnect With a Mentor Author Commented:
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:
http://ntt.cc/2008/11/21/tutorials-about-using-flash-player-10-to-verify-the-files-type-filereference.html
0
 
vindys80Connect With a Mentor Commented:
Hi,

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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.