I am storing images in a database and they can be in any of the generally accepted online formats (jpg, gif, png...).
I retrieve the images from online sources. I get them in as an array of bytes through the use of an inputstream and they are then stored in the database as BLOB's.
I would like to know if I can identify the content-type/mime-type from just the array of bytes. I know I could get the content-type when I retrieve the image by asking URLConnection for it, that is my back-up plan.
I've tried sending images to the browser without specifying the content-type and it works in the browsers I've tested with, but I realize this would essentially be incorrect.
What is actually stored anyway? Is it just the data that makes up the image (the data for the pixels), or is meta data also stored (like the mime-type).