views:

102

answers:

1

Related to: Flex SDK 3.5 - Check file mimetype

Is there a way to get a file's magic number in Flex SDK 3.5 in order to get the file type?

A: 

In my understanding the magic number is the first couple of bytes in a file. Also, in my opinion, this is a very loose term.

So assuming that the magic number is the first bytes in a file, you could open a byte stream and check the bytes read. I think this is the only reliable way (but also very error prone and might open security problems, think about IEs' content sniffing issues). The UNIX tool file actually does that and still, it is called a file type guesser.

The actual number depend on the file format you are trying to use. If you are lucky it's documented. If not, it might get painful.

ilikeorangutans