[resolved] How to Extract a files MIME type?

One Star

[resolved] How to Extract a files MIME type?

Hi I'm migrating an archived directory of files into a storage system, this system needs to have the mime type of the files inserted into its db.
I had hoped that either the tFileList or tFileProperties component would have the mime type but this is not present.
I've also tried several snippets of Java code as per http://stackoverflow.com/questions/51438/getting-a-files-mime-type-in-java, with no success.
Is there a talend component that can extract mime types? Alternately is there a piece of Java code that would do the job?
I could go down the route of parsing the extension out and using a crude lookup table but hope there is a more elegant way.
Cheers Andy
One Star

Re: [resolved] How to Extract a files MIME type?

Just worked this out;
Created new routine "mime" (Obviously needs some tidying)
"package routines;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class mime {
public static String main(String path) throws IOException {
Path source = Paths.get(path);
return Files.probeContentType(source);
}
}
"
Then used mime.main({path}) to get the mime_type.
This seams to work ok(only for java 7 I believe), would still be interested to hear if there is an OOB way to do this.