Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Mimes trait detects the wrong MIME type #830
scala> MimeTypes.mimeType("test.html") res0: String = application/octet-stream
scala> MimeTypes.mimeType("test.html") res0: String = text/html
Unfortunately, that's not the end of the story. Even with that fix,
scala> MimeTypes.mimeType("test.css") res1: String = application/x-pointplus
Now the problem is coming from
Other projects have already moved away from that library, being Apache Marmotta one of them that chose Apache Tika as an alternative (https://git-wip-us.apache.org/repos/asf?p=marmotta.git;a=commitdiff;h=f89f61f2128fcb70db885b31b42077782ad411a6), and it seems it's a quite reliable library.
scala> tika = new org.apache.tika.Tika tika: org.apache.tika.Tika = Apache Tika 1.18 scala> tika.detect("test.html") res2: String = text/html scala> tika.detect("test.css") res3: String = text/css
I'm fine with deprecating and eventually removing it, but it's currently being used in
In that case, the Content-Type auto-inference feature would have to be removed (which I believe never worked properly anyway).
I created PR to modify MIME Type guess against file path to use URLConnection.guessContentTypeFromName
This makes it possible to add an arbitrary MIME Type on the user code side.
It is good to refer to the following blog