In a web project, users upload their files, but when I receive them on the server, they are being stored as .tmp files rather than their original file extension (this is my preferred behavior as well).
However, this is causing a problem with Files.probeContentType()
. While locally for me, on my Linux dev machine, Files.probeContentType()
works correctly and does determine the right mime type, when I upload my project to the production server (amazon beanstalk), it doesn't seem to correctly determine the mime type.
From reading the javadocs, it seems that the implementation of Files.probeContentType()
are different, and I think that on production server, it is reading the file extension and so, is unable to determine the content type.
What's a good, and quick alternative to Files.probeContentType()
which will accept a File
argument and return a string like image/png
as the resulting mime type?