I have the below code for saving an image from a byte array.
I am able to save the image successfully using the below code.
Currently I am saving image with
There are many solutions. Very simple for example:
String contentType = URLConnection.guessContentTypeFromStream(new ByteArrayInputStream(imageBytes));
Or you can use third-party libraries. Like Apache Tika:
String contentType = new Tika().detect(imageBytes);