I’ve got bytes array in database.
How to extract file extension (mime/type) from byte array in java?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If this is for storing a file that is uploaded:
If you don’t have the original file, and you only have bytes, you have a couple of good solutions.
If you’re able to use a library, look at using mime-util to inspect the bytes:
http://technopaper.blogspot.com/2009/03/identifying-mime-using-mime-util.html
If you have to build your own byte detector, here are many of the most popular starting bytes: