Gray Watson

Greenhorn
+ Follow
since May 21, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gray Watson

Hey Marten:

How do envisage using this in conjunction with uploading a file. One stream is needed to download the stream to a file, and it seems another stream is required to use ContentInfoUtil to match the content info?



Right. Without using the wrapper, SimpleMagic will read in from the stream. I've just added to the repo a ContentInfoInputStreamWrapper class which you can read through that gives you the content information about the first bytes that were read.

is there an easy way to match the found content type with the file extension?



I've also just added a mapping from extension to the internal types. This is very limited right now. Take a look at ContentType code. I'd be happy to add a boatload of more entries.

Let me know if you've like me to push out 1.1 or if you can work from git directly.
gray
10 years ago
For posterity I've recently finished v1 of my SimpleMagic java package which reads the Unix magic(5) config files to support content-type detection.

More details, javadocs, documentation, source, etc. can be found at http://256.com/sources/simplemagic/
10 years ago