I get a file which is Base64 encoded string as the image. But I think the content of this contains information about file type like png, jpeg, etc. How can I detect that? Is there any library which can help me here?
相关问题
- Views base64 encoded blob in HTML with PHP
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- How to get the background from multiple images by
I did just this: (file is my base64 string)
This code is using regex pattern to extract mime type from Base64 string. Though it's written in JavaScript, you can try to implement the same thing in Java.
Usage:
Source: miguelmota/base64mime (GitHub)
I have solved my problem with using
mimeType = URLConnection.guessContentTypeFromStream(inputstream);
You can check like this:
Usage:
if you want to get Mime type use this one
online Demo here
===========================================
if you want to get only type of it like (png, jpg) etc
online Demo here